Reputation: 7940
I have a parent project with 2 submodules. I want to create a package with just project and dependant jars. Problem i am facing is all source files[java,scripts, configs] also get included in the artifact, can somebody help how to achieve this. Following is the descriptor i am using:
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>binaries</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<moduleSets>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>*:sub1</include>
<include>*:sub2</include>
</includes>
<binaries>
<outputDirectory>${artifactId}</outputDirectory>
<unpack>true</unpack>
<unpackOptions>
<excludes>
<exclude>**/resources/**</exclude>
<exclude>**/docs/**</exclude>
<exclude>**/src/**</exclude>
</excludes>
</unpackOptions>
<dependencySets>
<dependencySet>
<outputDirectory>${artifactId}/lib</outputDirectory>
<useProjectArtifact>true</useProjectArtifact>
<unpack>false</unpack>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
</binaries>
</moduleSet>
</moduleSets>
</assembly>
Upvotes: 0
Views: 886
Reputation: 97527
I would suggest to use this kind of assembly descriptor:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>xyz</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<dependencySets>
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<useTransitiveDependencies>true</useTransitiveDependencies>
<outputDirectory>lib</outputDirectory>
<unpack>false</unpack>
<excludes>
<exclude>${project.groupId}:*:*</exclude>
</excludes>
</dependencySet>
</dependencySets>
<moduleSets>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<binaries>
<outputDirectory>modules</outputDirectory>
<unpack>false</unpack>
</binaries>
</moduleSet>
</moduleSets>
</assembly>
Based on your descriptor i would suggest to use <includeBaseDirectory>true</includeBaseDirectory>
cause you prefixed all ouputDirectories with ${artifactId}
.
The above descriptor will create a zip file which contains sub-folders lib which contains the dependencies and a folder modules
which contains the modules of your multi-module build.
Furthermore i would suggest to create a separate module which is responsible for creating the archive.
If your resulting zip contains java source files etc. it sounds you are doing the assembly step within a module which is of packaging jar
.
Upvotes: 1