When doing a mvn install
I want to end up with 2 WAR files in my target directory. One will contain the production web.xml
and the
Sort-of-ugly hack (it breaks Maven's idea of declaring intentions instead of actions), but worked for me: I had to generate two wars which shared the same back-end code base, but varied on the MVC controller packages.
After banging my head with several plugins, I thought "hey, I'd do it easily in ant", which lead me to use <maven-antrun-plugin>
to generate the wars during the "package" phase (on which we arlready have all the files). Sort of like this:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<delete file="target/war-1.war" />
<delete file="target/war-2.war" />
<war destfile="target/war-1.war">
<fileset dir="target/original">
<exclude name="**/WEB-INF/classes/package_of_war2/**" />
</fileset>
</war>
<war destfile="target/war-2.war">
<fileset dir="target/original">
<exclude name="**/WEB-INF/classes/package_of_war1/**" />
</fileset>
</war>
<delete file="target/original.war" /
</tasks>
</configuration>
</execution>
</executions>
</plugin>
(to be fair, I did not delete the original file, but you should be able to do so.)
In your case, you could package one war without the alternate web.xml, rename/move it over the original web.xml, then package the second war.
While I don't use Maven but Ivy instead, here's how you should generally do this:
Have your own application published in to a private repository/similar as JAR with its dependencies/other static stuff and then individual project settings for building the application's deployment specific WARs with context specific configurations. Now by building any of the individual deployment projects you get the latest version of your actual application with its build specific configurations.
I would assume that since this is trivial in Ivy, Maven should be able to do it just as easily.