maven-assembly-plugin: How to Create ‘.tar.gz’ or ‘.zip’ Archive for Java Enterprise Project using Maven?

Maven is pretty amazing. With so many plugins it is one of the Best Java Build tool in the market right now. I use it in all of my projects and heavily depends on it. Build possibilities are endless. Some time back I’ve written different tutorials on so many other maven plugins and in this one we will go over maven-assembly-plugin. Maven Assembly Plugin relies on the provided assembly descriptors to dictate its execution.

Here is a list of previous maven plugins tutorial:

  • maven-war-plugin – Create project .war file:
  • maven-resources-plugin, maven-dependency-plugin & maven-jar-plugin – Build Java Project including all Dependencies?
  • maven-shade-plugin – Create Java+Spring Based executable .jar with all Required Dependencies, Properties and Resources:

Let’s get started with maven-assembly-plugin


Create New Maven project in Eclipse environment. Name it as CrunchifyMavenBuildPlugins. If you have existing Dynamic Web Project or Java Project then using these steps you could convert project to maven project. After converting project to Maven you should see pom.xml file generated which we need for this tutorial.

Here is my project structure. I’m using my existing project which has total 8 java files under /src/com/crunchify/tutorials package.

maven assembly plugin - Crunchify Tutorial


Open your project’s pom.xml file add new <plugin></plugin> mainly line 28 to 38.


Create new file crunchify.xml and put it under /src/com/crunchify/assembly package. We have referred this file already in above pom.xml file.

Here we are exporting our project into 3 different <formats>

  • tar.gz
  • zip
  • tar

<directory> tag shows that – get everything under package src/com/crunchify/tutorial and put it under crunchify-output folder which is mentioned under <outputDirectory> tag.

If you want to include everything like /src or /resource folder contents then you could use below below different variations:

  1. <directory>src/com/crunchify/tutorial</directory>
  2. <directory>src</directory> : everything under src folder
  3. <directory>resources</directory> : everything under resources folder
  4. <directory>/</directory> : everything


Right click on project CrunchifyMavenBuildPlugins => Run As => Maven build

Maven Right Click and Clean Build - Crunchify

  • Provide Goals as clean assembly:assembly
  • Click Apply
  • Click Run

Create assembly using eclipse build command


You should see BUILD SUCCESS message on console.


<NOTE> you don’t have to perform this step

tarLongFileMode for maven deployment descriptor - maven assembly plugin

Are you getting this error? If you see this error message while building assembly then you have to add below line to pom.xml file.

I got above error on my 1st attempt. So already added tarLongFileMode to above pom.xml file.


Now how to verify? Please go to your project’s target folder and run below command to see your .tag.gz file contents.

bash-3.2$ tar zxvf CrunchifyMavenBuildPlugins-0.0.1-SNAPSHOT-bundle.tar.gz

maven assembly plugin - verify result - crunchify

Have anything to add to this article? Please chime in and join the conversion.