I have a project where I am attempting to overlay a pre-built war with a compiled jar from another module and some files in the war project.
+pom.xml
|
+-+depandancy_dir
| |
| + source.war
|
+-+ jar
| |
| + pom.xml
| + src
| ...
|
+-+war_dir
|
+ pom.xml
+ src
.... no jars
I want to exclude some of the jars that are configured as maven dependencies for the jar.
I have tried all of the following exclude lines in the pom for the war. the undesired jar shows up regardless.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<dependentWarExcludes>**/unwanted-core-1.1.jar</dependentWarExcludes>
<overlays>
<overlay>
<groupId>src.war</groupId>
<artifactId>base.war</artifactId>
<excludes>
<exclude>**/unwanted-core-1.1.jar</exclude>
<packagingExcludes>**/unwanted-core-1.1.jar</packagingExcludes>
<exclude>WEB-INF/lib/unwanted-core-1.1.jar</exclude>
<packagingExcludes>WEB-INF/lib/unwanted-core-1.1.jar</packagingExcludes>
</excludes>
</overlay>
</overlays>
</configuration>
</plugin>
I am running maven under eclipse. The war plugin reports version maven-war-plugin:2.2:war
Turns out I was attempting to solve the problem the wrong way. The exclusion goes on the dependency.
<dependencies>
<dependency>
<!-- the jar of custom code -->
<groupId>my.group</groupId>
<artifactId>jar</artifactId>
<version>1.0.0-SNAPSHOT</version>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>org.unwanted</groupId>
<artifactId>unwanted-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<!-- the war I am overlaying -->
<groupId>my.group</groupId>
<artifactId>a.base.war</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/../dependancies/jreport.war</systemPath>
<type>war</type>
</dependency>
</dependencies>
The following links helped me.
https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html