Situation is pretty straightforward. I have a Java webapp that I\'m converting to be built with Maven. At present, the app is built with Ant into a single WAR file, which is the
All of that to say: is there a straightforward way to build the WAR and package that into this trivially-simple EAR? I'd like to avoid maintaining these as two separate projects, but would similarly prefer not to resort to an overly messy hack using assemblies to accomplish this.
Short answer: no, there is no simple maven-way to do that as this would go against a Maven rule which is "one artifact per project" (understand one output per project which is true in 99% of the cases).
And actually, I would strongly recommend to not go the hacky way and forget using assemblies to create an EAR. Instead, create two modules, one with a packaging of type war
, the other with a packaging of type ear
depending on the war artifact and declare them as modules of a parent pom.xml
. Like this:
my-project
|-- pom.xml // packaging of type pom and my-war and my-ear as modules
|-- my-war
| `-- pom.xml // packaging of type war
`-- my-ear
`-- pom.xml // packaging of type ear
If you go for Maven, adopt Maven philosophy, don't fight against it, it will save you lot of pain. Seriously, hacking assemblies to do what the maven-ear-plugin is already doing is just anti DRY. You'd better stick to Ant in that case.