Reputation: 12416
I am using Maven assembly plugin with which I generate single Jar file with all dependencies for my application (unpacked by definition in jarlib.xml
given here: https://gist.github.com/knyttl/7cc0730ae0fb6947cbda). This dependency.jar
can be then put on class path with my application.jar
and run as java -cp application.jar:dependencies.jar my.class.Runner
. The problem are however multiple versions of the same artifacts when unpacking jars.
For instance I am using org.apache.xmlrpc:xmlrpc-server:jar:3.1.3
which depends on javax.servlet:servlet-api:jar:2.3
. In my application I need to use different, newer version of the javax.servlet
, but when unpacking, the new version is skipped and the old one is used instead.
xmlrpc-server
?javax.servlet
?-cp application.jar:dependencies.jar
? When I tried to build the jar without unpacking, none of the inner jar classes were found when running the application.Upvotes: 0
Views: 332
Reputation: 12416
The best solution I found is using <exclusions>
directly in the <dependency>
tag directly in the pom, without any plugins.
Upvotes: 1
Reputation: 11723
Sounds like what you really want is the shade plugin - the ability to create a single jar with all of these included. https://maven.apache.org/plugins/maven-shade-plugin/examples/includes-excludes.html
Upvotes: 1