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 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 us to create zip file for the application.

Configuring Assembly XML

So we 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 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 we have set to false.

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

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

We exclude 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 we 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, we have few things configured.

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

We give the zip archive name using tag <finalName/>. For our case, the final zip file is

We use <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 *