Reputation: 138
I have a maven3 webapp (war) project that has 3 dependencies. The war dependency is (a 3rd party lib that I have no control over) -- httpclient-4..jar httpcore-4..jar httpcore-nio-4.*.jar
The 3rd party war dependency has a dependency on their defined version of http which is clashing with the later version I need to use.
The following steps occur during a package of my app.
My http jar is copied to /WEB-INF/lib/ The .war dependency which also includes http above is built and overlaid on top of my target Final .war file is created from target
Here,I have managed to exclude/remove the earlier version of http, but now i want to add my own dependency versions of the above jars like: httpclient-4.5.6.jar httpcore-4.3.jar httpcore-nio-4.3.jar
How can i copy while the war is trying to pack my level of change which will not contain 3rd party prev. versions?
My pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.fit.check.plan.test</groupId> <artifactId>ui-cust</artifactId> <version>10.2.0.0.0-test</version> <relativePath>../</relativePath> </parent>
<properties> <sharedlib.name>ui-shared-lib</sharedlib.name> <sharedlib.vendor>TEST UI</sharedlib.vendor> <atmosphere-version>2.2.0</atmosphere-version> <spec-version>10.2.0.0.0</spec-version> <epc.version>9.1</epc.version> <sonar.skip>true</sonar.skip> </properties>
<artifactId>ui-shared-test-lib</artifactId> <packaging>war</packaging>
<build> <finalName>ui-shared-lib</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.8</version> <executions>
<execution>
<id>unpack-shared-lib-war</id>
<phase>validate</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.fit.check.plan.fe</groupId>
<artifactId>ui-shared-lib</artifactId>
<version>${plan.version}</version>
<type>war</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/ui-lib-test</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.8</version> <executions>
<execution>
<id>copy-test-ui-lib-jar</id>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${test.test.groupId}</groupId>
<artifactId>implementation-interfaces</artifactId>
<version>${test.test.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/ui-lib-test/WEB-INF/lib</outputDirectory>
<destFileName>implementation-interfaces.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>${artifact.findbugs-jsr305.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/ui-lib-test/WEB-INF/lib</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>com.fit.check.TEST</groupId>
<artifactId>TEST-context-store-ws</artifactId>
<version>${TEST.version}</version>
<classifier>clientkit</classifier>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/ui-lib-test/WEB-INF/lib</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>com.fit.check.plan.test</groupId>
<artifactId>test-activities-lib</artifactId>
<version>${test.test.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/ui-lib-test/WEB-INF/lib</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>com.fit.check.plan.test</groupId>
<artifactId>test-core-lib</artifactId>
<version>${test.test.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/ui-lib-test/WEB-INF/lib</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>com.fit.check.cell</groupId>
<artifactId>security-service-war</artifactId>
<version>${TEST.version}</version>
<classifier>clientkit</classifier>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/ui-lib-test/WEB-INF/lib</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>com.fit.check.cell</groupId>
<artifactId>aff-war</artifactId>
<version>${TEST.version}</version>
<classifier>clientkit</classifier>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/ui-lib-test/WEB-INF/lib</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>com.fit.check.plan.test</groupId>
<artifactId>common-groovy-api</artifactId>
<version>${test.test.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/ui-lib-test/WEB-INF/lib</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>com.fit.check.plan.test</groupId>
<artifactId>task-util-service-ws</artifactId>
<version>${test.test.version}</version>
<classifier>clientkit</classifier>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/ui-lib-test/WEB-INF/lib</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>com.fit.check.TEST</groupId>
<artifactId>TEST-services-war</artifactId>
<version>${TEST.version}</version>
<classifier>clientkit</classifier>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/ui-lib-test/WEB-INF/lib</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>com.fit.check.plan.test</groupId>
<artifactId>test-core-override</artifactId>
<version>${test.test.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/ui-lib-test/WEB-INF/lib</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>ui-shared.war</warName>
<outputFileNameMapping>@{artifactId}@-@{baseVersion}@@{dashClassifier?}@.@{extension}@</outputFileNameMapping>
<failOnMissingWebXml>false</failOnMissingWebXml>
<archive>
<manifest>
<addDefaultImplementationEntries>false</addDefaultImplementationEntries>
</manifest>
<compress>true</compress>
<manifestEntries>
<Specification-Title>${sharedlib.name}</Specification-Title>
<Specification-Version>${spec-version}</Specification-Version>
<Implementation-Title>${sharedlib.name}</Implementation-Title>
<Implementation-Vendor>${sharedlib.vendor}</Implementation-Vendor>
<Extension-Name>${sharedlib.name}</Extension-Name>
</manifestEntries>
</archive>
<warSourceDirectory>${project.build.directory}/ui-lib-test</warSourceDirectory>
<packagingIncludes>WEB-INF/lib/*.jar</packagingIncludes>
<packagingExcludes>
<![CDATA[WEB-INF/lib/slf4j-log4j12*.jar,
WEB-INF/lib/amf_toolkit-9.0.0.pb00_hf02.jar,
WEB-INF/lib/commons-beanutils-1.9.2.jar,
WEB-INF/lib/commons-fileupload-1.3.3.jar,
WEB-INF/lib/httpclient-4.1.2.jar,
WEB-INF/lib/httpcore-4.2.4.jar,
WEB-INF/lib/httpcore-nio-4.2.4.jar]]>
</packagingExcludes>
</configuration>
</plugin>
</plugins> </build> </project>
--package excluded in bold---
Upvotes: 0
Views: 55
Reputation: 5468
You can on the unpack
actually specify excludes
on both the artifactItem
and the main configuration
. You can see an example of this here: Unpacking specific artifacts
This would allow you to before packaging exclude the dependencies that you don't want, from there the packagingIncludes
on the maven-war-plugin
would pull in all the required items.
Alternatively you could add a step before it that does another maven-dependency-plugin
execution that does the copying of your specific artifacts.
Upvotes: 1