Creating ZIP for Dependencies using Maven Assembly Plugin


This post is about creating zip for dependencies using maven assembly plugin. Sometimes you may need to create a zip from your application with dependencies only, i.e., to include only the jar libraries which are being used for your application.

Then this tutorial will help you to understand how to create such zip file for jar libraries. Generally this kind of situation occurs in multi module project or for the single project also you may need to create zip file separately with jars only and such zip file is used for configuration purpose for your project or application.

Maven Assembly Plugin

Maven assembly plugin (maven-assembly-plugin) helps you to create zip file for your application.

Configuring Assembly XML

First thing is you need to configure an XML file (assembly.xml or any other name you want) under the application’s root directory or elsewhere with the following structure:


You should put everything you want to configure inside <assembly/> tag.

You must give an id value to the <assembly/>, for example, <id>zipLib</id>, with any value you wish to give.

<includeBaseDirectory/> is by default set to true, which will result in the project’s artifactId-version and it is being used as the assembly base directory. However, in some special cases you may want to use a different directory name for the root of your assembly. That’s why I have set to false.

To include all dependencies or jar files into the zip file I have used <dependencySets/> that includes one or more <dependencySet/> tag(s).

I specified the output directory as lib, so all jar files will be put under the sub-directory lib inside the zip file.

I excluded the project’s or application’s generated jar file which is not required generally but, if you need it then you can include it. To include it simple remove <excludes/> tag.

Configuring Assembly Plugin

Now I will configure maven-assembly-plugin to generate appropriate archive.

Notice here packing type is by default jar.

<project xmlns="" xmlns:xsi=""

Look at the maven-assembly-plugin, I have configured few things in the above content.

I have set false to <appendAssemblyId/> to indicate that I don’t want to append the assembly id – zip – with the final zip archive.

I gave the zip archive name using tag <finalName/>. For my case, the final zip file is

I used <descriptor/> tag to include the assembly.xml file.

Now building the maven project or application will produce the appropriate zip file with jar files included under the lib sub-directory.

Thanks for reading.

Leave a Reply

Your email address will not be published. Required fields are marked *