Assembly ******** Links ===== - http://maven.apache.org/plugins/maven-assembly-plugin/ - The best documentation I can find for the assembly descriptor is in Subversion: https://svn.apache.org/repos/asf/maven/plugins/tags/maven-assembly-plugin-2.1/src/main/mdo/descriptor.mdo Sample Project -------------- sample-maven-assembly_ Command ======= :: mvn assembly:assembly POM === Add the following to your ``pom.xml``: :: maven-assembly-plugin 2.1 src/main/assembly/classes-for-app.xml **Note**: - The assembly descriptor is located in ``src/main/assembly/`` which is the standard location for assembly descriptors. - I am specifying version 2.1 as ``2.2-beta-1`` adds the artifact folder to the root of the zip file. For more information see `JIRA Issue - MASSEMBLY-179`_ 18/07/2007 08:54 Looks like this issue might be fixed in the latest snapshot of the plugin. Goal ---- If you want this to run every time you run a ``install`` goal. Add the ``executions`` section to your ``pom.xml`` file: :: maven-assembly-plugin src/main/assembly/classes-for-app.xml assembly install assembly 23/07/2007 09:08 One of our projects is using the ``attached`` goal. This might deploy the assembly to the remote repository. See `assembly:attached`_. Output Directory ---------------- To control the output directory add the following to the ``configuration`` section in ``pom.xml``: :: ... maven-assembly-plugin dep.xml target/output Assembly Descriptor =================== The file: :: src/main/assembly/classes-for-app.xml defines your assembly. An example file: :: classes-for-app jar false target/classes / / true runtime log4j:log4j `JIRA, MASSEMBLY-179`_ Assembled jar includes artifact names in path: *dependency sets with unpack == true no longer use at all*. Dependencies ------------ *Include* If you prefer, you can specify the files to include rather than files to exclude. Replace the ``excludes`` section with the following: :: / true runtime log4j:log4j commons-pool:commons-pool ... *Exclude* To exclude a jar file and it's dependencies, add the provided scope to the dependency in ``pom.xml``: :: com.thecompany lucene-app 0.1 provided Executable JAR File ------------------- An executable jar file can be build by adding this configuration to the ``pom.xml`` file: :: maven-assembly-plugin 2.1 com.sample.App jar-with-dependencies assembly install assembly The ``mainClass`` should be modified as required. *Issues* In a multi module build, the assembly will fail to build from the root folder with this message: :: No assembly descriptors found. To solve this problem, I added the ``execution`` section as above, so the assembly automatically builds during the ``install`` phase. Other people have the same issue, `Assembly one of the modules`_, but I didn't exactly follow their solution. Fileset ------- To exclude the ``objectstest`` folder from the assembly: :: target/classes **/objectstest/ Formats ------- To produce a ``zip`` file: :: zip Multi Module ============ Multiple Assemblies ------------------- Make sure to specify the version of the plugin in the parent pom: :: maven-assembly-plugin 2.1 ...we don't want to risk mixing the versions of the plugin. Project Modules Only -------------------- To only assemble jar files from this project add the ``projectModulesOnly`` tag (*I don't know if this works*): :: maven-assembly-plugin src/main/assembly/classes-for-app.xml true .. _sample-maven-assembly: http://toybox/hg/sample/file/tip/java/maven/sample-assembly .. _`JIRA Issue - MASSEMBLY-179`: http://jira.codehaus.org/browse/MASSEMBLY-179 .. _`assembly:attached`: http://maven.apache.org/plugins/maven-assembly-plugin/attached-mojo.html .. _`JIRA, MASSEMBLY-179`: http://jira.codehaus.org/browse/MASSEMBLY-179 .. _`Assembly one of the modules`: http://www.nabble.com/Assembly-one-of-the-modules-tf1543053s177.html#a4191401