Saturday, June 8, 2013

Maven package all jar dependencies into one jar

Many times you would have wanted to combine your main class code along with all dependent project jars into single jar which helps in easy distribution of your project. You can acheive the same using below maven plugin.

To generate the assembled jar, execute below command
  • mvn assembly:assembly -DdescriptorId=jar-with-dependencies
If you want to do this as part of regular maven package command, then include below execution tag after configuration tag  in above pom
      <id>make-assembly</id> <!-- this is used for inheritance merges -->
      <phase>package</phase> <!-- bind to the packaging phase -->

Courtesy :