These are brief examples of how to use the assembly:assembly and assembly:unpack goals.
To use the assembly:assembly goal, you must define the descriptor file that you are going to use or define the descriptorId from the predefined descriptor ids.
mvn assembly:assembly -Ddescriptor=path/to/descriptor.xml
There may be some situations that you only needed the jars of your project modules. You may exclude their dependencies but what if you have 10 modules with 10 dependencies each? Isn't it a bit hassle to exclude 100 where you only needed 10. To achieve this goal, set the "projectModulesOnly" parameter to true and maven will do it for you.
mvn assembly:assembly -DprojectModulesOnly=true
mvn assembly:assembly -DdescriptorId=bin or mvn assembly:assembly -DdescriptorId=jar-with-dependencies or mvn assembly:assembly -DdescriptorId=src
You can also configure this plugin inside your pom.xml. To run use "mvn assembly:assembly".
<project> ... <build> ... <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.0-beta-1</version> <configuration> <descriptor>path/to/descriptor.xml</descriptor> <finalName>final_name</finalName> <outputDirectory>output/directory</outputDirectory> <workDirectory>target/assembly/work</workDirectory> </configuration> </plugin> </plugins> ... </build> ... </project>
After running this goal, all dependencies will be extracted into the location specified in the <workDirectory> element.
For full documentation of plugin's goals and parameters, click here.
The simplest descriptor you can create for assembly a repository would be something like the following:
<assembly> <id>bin</id> <formats> <format>zip</format> </formats> <repositories> <repository> <outputDirectory>repository</outputDirectory> </repository> </repositories> </assembly>
With no includes or excludes specified all dependencies are used to create a repository. In fact when you specify no includes the default will be to include them all, but you can still specify excludes if you need to keep certain artifacts from making it into the repository you're trying to assemble.
By default no repository metadata is generated when the repository is assembled. If you are trying to create a repository that is going to be used as a remote repository then you will need to have the metadata generated in order to for it to function properly as a remote repository. To do this just enable repository metadata generation by using the includeMetadata element:
<assembly> <id>bin</id> <formats> <format>zip</format> </formats> <repositories> <repository> <outputDirectory>repository</outputDirectory> <includeMetadata>true</includeMetadata> </repository> </repositories> </assembly>
Keep in mind that any dependencies specified in the POM will have their transitive dependencies placed in the assembly as well.