Generating WAR and EAR artifacts inside the same G

2019-05-04 07:04发布

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条回答
Bombasti
2楼-- · 2019-05-04 07:47

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

ear {
    from war.outputs.files
}
查看更多
登录 后发表回答