The assembly mechanism in Maven 2.x provides an easy way to create distributions using a assembly descriptor and dependency information found in you POM. In order to use the assembly plug-in you need to configure the assembly plug-in in your POM and it might look like the following:
<project> <parent> <artifactId>maven</artifactId> <groupId>org.apache.maven</groupId> <version>2.0-beta-3-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <groupId>org.apache.maven</groupId> <artifactId>maven-embedder</artifactId> <name>Maven Embedder</name> <version>2.0-beta-3-SNAPSHOT</version> <build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.2-beta-2</version> <configuration> <descriptor>src/main/assembly/dep.xml</descriptor> </configuration> </plugin> </plugins> </build> ... </project>
You'll notice that the assembly descriptor is located in ${basedir}/src/main/assembly which is the standard location for assembly descriptors.
This is the most typical usage of the assembly plugin where you are creating a distribution for standard use.
<assembly> <id>bin</id> <formats> <format>tar.gz</format> <format>tar.bz2</format> <format>zip</format> </formats> <fileSets> <fileSet> <includes> <include>README*</include> <include>LICENSE*</include> <include>NOTICE*</include> </includes> </fileSet> <fileSet> <directory>target</directory> <outputDirectory></outputDirectory> <includes> <include>*.jar</include> </includes> </fileSet> </fileSets> </assembly>
<assembly> <!-- TODO: a jarjar format would be better --> <id>dep</id> <formats> <format>jar</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> <fileSets> <fileSet> <outputDirectory>/</outputDirectory> </fileSet> </fileSets> <dependencySets> <dependencySet> <outputDirectory>/</outputDirectory> <unpack>true</unpack> <scope>runtime</scope> <excludes> <exclude>junit:junit</exclude> <exclude>commons-lang:commons-lang</exclude> <exclude>commons-logging:commons-logging</exclude> <exclude>commons-cli:commons-cli</exclude> <exclude>jsch:jsch</exclude> <exclude>org.apache.maven.wagon:wagon-ssh</exclude> <!-- TODO: can probably be removed now --> <exclude>plexus:plexus-container-default</exclude> </excludes> </dependencySet> </dependencySets> </assembly>
<assembly> <id>src</id> <formats> <format>tar.gz</format> <format>tar.bz2</format> <format>zip</format> </formats> <fileSets> <fileSet> <includes> <include>README*</include> <include>LICENSE*</include> <include>NOTICE*</include> <include>pom.xml</include> </includes> </fileSet> <fileSet> <directory>src</directory> </fileSet> </fileSets> </assembly>
mvn assembly:assembly