Reputation: 53
I have a Maven multi-module project. In one module, we create a ZIP with maven-assembly-plugin plugin. The configuration for this:
<baseDirectory>/</baseDirectory>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>true</useProjectArtifact>
<excludes>
<exclude>
com.sample.blabla:test-core-client
</exclude>
</excludes>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
And the pom config for this:
<execution>
<id>make-service-client-with-dependencies-zip</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>${service-client-with-dependencies.zip.filename}</finalName>
<appendAssemblyId>true</appendAssemblyId>
<outputDirectory>${project.build.directory}/zip</outputDirectory>
<descriptors>
<descriptor>src/main/assembly/test-service-client-with-dependencies.xml</descriptor>
</descriptors>
</configuration>
</execution>
Unfortunately the created ZIP contains much more jar-s, that we would like... for example: 37 X maven-XXX JAR, a lot of spring jars, wagon jars,...etc.
But we wouldn't like to include these jars, just which necessary for runtime. How can we do it?
Upvotes: 0
Views: 1352
Reputation: 328566
You use the descriptor test-service-client-with-dependencies.xml
which includes everything and the kitchen sink in the result.
Use jar-with-dependencies
instead. That will include entry runtime dependencies (local and transient).
If that is still too much, then you can omit dependencies by declaring them as <scope>provided</scope>
(if someone else will add them to the classpath later), <scope>test</scope>
(if the dependency is only necessary to run the tests) or <optional>true</optional>
if this is an optional dependency.
Upvotes: 0
Reputation: 52635
Maven assembly plugin includes only the jars which are in runtime
scope as per your configuration. You can run mvn dependency:tree
and compare the output with the contents of your zip.
You can try setting the property useTransitiveDependencies
to false
. This will exclude all transitive dependencies from the zip. But this can have unpleasant side-effects.
Upvotes: 2