I've following in my pom.xml
...
<groupId>my.org.name</groupId>
<artifactId>webservices-webapp</artifactId>
<packaging>war</packaging>
<name>Webapp</name>
<dependencies>
...
</dependecies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<attachClasses>true</attachClasses>
<packagingExcludes>
WEB-INF/lib/avalon-*.jar,
WEB-INF/lib/geronimo-*.jar,
WEB-INF/lib/aopalliance-*.jar,
WEB-INF/lib/common-*.jar,
WEB-INF/lib/core-cryptor-*.jar,
WEB-INF/lib/logging-*.jar,
WEB-INF/lib/rm-security-*.jar,
WEB-INF/lib/security-context-shared-*.jar,
WEB-INF/lib/session-management-*.jar,
WEB-INF/lib/jax*.jar,
WEB-INF/lib/joda-time-*.jar,
WEB-INF/lib/opensaml-*.jar,WEB-INF/lib/spring-security-core-*.jar,
WEB-INF/lib/xmlsec-*.jar,WEB-INF/lib/xmltooling-*.jar,
WEB-INF/lib/stax-api-*.jar,
WEB-INF/lib/servlet-api-*.jar,WEB-INF/lib/axis-saaj-*.jar,WEB-INF/lib/axis-jaxrpc-*.jar,
%regex[WEB-INF/lib/spring-(?!web).*.jar]
</packagingExcludes>
<archive>
<manifestEntries>
<DisableIBMJAXWSEngine>true</DisableIBMJAXWSEngine>
</manifestEntries>
</archive>
<webResources>
<resource>
<directory>src/main/java</directory>
<targetPath>WEB-INF/classes</targetPath>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
<finalName>${project.artifactId}</finalName>
</build>
Now when I do mvn clean install. I get all jars in the target/webapp/WEB-INF/lib actually I shouldn't get the jars matching excluded patters like avalon-.jar,geronimo-.jar,aopalliance-.jar,common-.jar etc..
Why are these excluded jars coming in WEB_INF/lib??
packagingExcludes: The comma separated list of tokens to exclude from the WAR before packaging. With packagingExcludes, the tokens are completely excluded from the final war file. With warSourceExcludes, the tokens are just ignored when copying the war directory into the war file.
We can have multiple transitive dependencies can be excluded by using the <exclusion> tag for each of the dependencies we want to exclude and placing all these exclusion tags inside the <exclusions> tag in pom. xml.
packagingExcludes
applies to war archive. It has no impact to "exploded" war.
Reference: https://github.com/apache/maven-plugins/blob/maven-war-plugin-2.6/src/main/java/org/apache/maven/plugin/war/packaging/WarProjectPackagingTask.java#L109
(handleArtifacts( context ) is called regardless of packagingExcludes
packagingExcludes
exclude jar files.
But if application is spring boot, in the repackaging phase, it puts all the jars back in new package and renames old package to .war.original
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With