问题
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