Reputation: 4719
Currently our maven build includes all the dependencies in the jar, using jar-with-dependencies
.
We want to split this into two separate jars, one with the project application code and files, and one with the dependencies.
How is this done?
Thanks
Upvotes: 0
Views: 60
Reputation: 1796
Use the maven-shade-plugin instead with following configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<configuration>
<finalName>${project.artifactId}-${project.version}-libs</finalName>
<artifactSet>
<excludes>
<exclude>${project.groupId}:${project.artifactId}</exclude>
</excludes>
</artifactSet>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
The trick is to define a specific final name. This avoids the replacement of the default jar, which is packaged by the maven-jar-plugin. The default name is ${project.artifactId}-${project.version}. So simply add a suffix like libs. Then exclude the artifact itself, because the classes should not be packaged twice.
The build will result in two jar files:
Upvotes: 0
Reputation: 2883
This is done using the maven Assembly plugin
http://maven.apache.org/plugins/maven-assembly-plugin/
Upvotes: 1