Generating WAR and EAR artifacts inside the same Gradle project

删除回忆录丶 提交于 2020-01-02 05:46:20

问题


Suppose that I have a Gradle web project with a standard web project layout src/main/webapp.

Project myproject-web, build.gradle:

apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'war'

I know that I can wrap the resulting .war file generated by myproject-web inside an .ear if I define a secondary project (say, myproject-ear) which applies the ear plugin and references myproject-web as a dependency:

Project myproject-ear, build.gradle:

deploy project(':myproject-web')

I know it's a bit pointless to create an .ear file with only one .war inside (but that's how I'm required to deliver artifacts at my current job). So would it be possible to entirely skip the definition of the project myproject-ear and just use the ear plugin directly inside myproject-web's build file?

Thanks!


回答1:


Add the ear plugin to your war project, then add the war into the ear using the following configuration:

ear {
    from war.outputs.files
}


来源:https://stackoverflow.com/questions/23633933/generating-war-and-ear-artifacts-inside-the-same-gradle-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!