Maven - web.xml package generated by the Configuration Processor plugin
There is a snippet in our web.xml that is only required for development, it shouldn't be present when the application is deployed in production. I would like to use the Configuration Handler Plugin to remove this snippet when Maven was called with a production profile.
The conversion itself is easy, but what would be the best way to package this generated web.xml file into a WAR ? I was outputting the converted web.xml to the target directory / generated sources. When the production profile is active, I would like Maven to use this web.xml instead in the src directory. If this profile is not active, the default location should be used.
source to share
I would create a property, say, webXml.path
and configure Maven like this:
<properties>
<webXml.path>src/main/webapp/WEB-INF/web.xml</webXml.path>
</properties
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>${webXml.path}</webXml>
</configuration>
</plugin>
</plugins>
</build>
...
<profiles>
<profile>
<id>prod</id>
<properties>
<webXml.path>target/generated-sources/web.xml</webXml.path>
</properties>
</profile>
</profiles>
source to share