May 19, 2012

Create a maven distribution package including a jar with dependencies

In this post I will show how to create a distribution package (zip/tar.gz) using maven. Package will contain the executable jar and other relevant file such as README, License etc.

First I will create the jar including all the dependencies. To do that I add following code to my pom.xml

In this pom.xml, it reffers to another xml file call dist.xml. This xml file contains all the details about the distribution package we are going to generate.
<assembly xmlns=""

You should note following thing on pom.xml and dist.xml.

In pom.xml

  • Replace this " <mainclass<HelloWorld.App</mainclass> " with your main class.
  • Replace this " <descriptor>src/main/dist.xml</descriptor> " with your dist.xml file path.

In dist.xml

  • Use <files> to add files.
  • Use <fileSets> to add directories.
  • Use <outputDirectory> to specify the destination of each file/directory.

For more details : Maven assembly plugin examples