To enable filtering of
web.xml you must configure the WAR Plugin like this:
<plugin> <artifactId>maven-war-plugin</artifactId> <version>2.1.1</version> <configuration> <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors> </configuration> </plugin>
Examples can be found here.
When used, the copy of the dependency artifact in your project will have the classifier appended to its filename. This can be used to differentiate duplicate artifacts.
Give it a "provided" scope.
dependentWarExclude is used in overlays for excluding dependent
WAR files from the assembled webapp.
<exclude> parameter to identify the tokens to exclude.
For more information refer to Adding and Filtering External Web Resources.
dependentWarExcludes parameter to identify the tokens to exclude.
For each goal, you can use the documentation from the plugin site.
If you need a specific version, generate it using
mvn site:site or use:
mvn help:describe -Dplugin=war -Dfull=true -Dversion=<your-plugin-version-here>
If you would simply like to package the classes and resources as a JAR in
rather than as loose files under
WEB-INF/classes, use the following configuration:
<plugin> <artifactId>maven-war-plugin</artifactId> <version>2.1.1</version> <configuration> <archiveClasses>true</archiveClasses> </configuration> </plugin>
If you need to re-use this JAR in another project, the recommended approach is to move the classes to a separate module that builds a JAR, and then declare a dependency on that JAR from your webapp as well as from any other projects that need it.
If you can't move the classes to another project, you can deploy the classes and resources included in your webapp as an "attached" artifact, with a classifier, by using the following configuration:
<project> ... <artifactId>mywebapp</artifactId> <version>1.0-SNAPSHOT</version> ... <build> <plugins> <plugin> <artifactId>maven-war-plugin</artifactId> <version>2.1.1</version> <configuration> <attachClasses>true</attachClasses> </configuration> </plugin> </plugins> </build> ... </project>
This will result in two artifacts being deployed: