Maven: Packaging all dependencies in a single JAR
Add maven-assembly-plugin to your pom.xml and bind it to the package lifecycle event. mvn clean package will do the trick.
<project> [...] <build> <plugins> <plugin> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <mainClass>fully.qualified.MainClass </mainClass> </manifest> </archive> </configuration> </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies </descriptorRef> </descriptorRefs> </configuration> <executions> <execution> <id>make-my-jar-with-dependencies</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> [...] </plugins> [...] </build> </project>
About this entry
You’re currently reading “Maven: Packaging all dependencies in a single JAR,” an entry on Singaram's Tech Musings
- Published:
- April 24, 2011 / 12:48 PM
- Category:
- Apache Maven
- Tags:
- Apache Maven, Assembly Plugin, Jar, POM

No comments yet
Jump to comment form | comment rss [?] | trackback uri [?]