Copying dependencies with Maven

In a previous post I put here how to create fat jars using Maven, now Let’s see how to copy the necessary dependencies, setup the classpath and execute the jar without unpacking any of the dependencies.

To do this we’ll need two plugins :
maven-jar-plugin
maven-dependency-plugin

maven-jar-plugin is the one that will create and configure META-INF/MANIFEST.MF containing the main class and all the related dependencies.

maven-dependency-plugin will pickup and put all the dependencies in the right place.

Let’s take a look.

Using this configuration, all our dependencies will be placed into /lib folder and the jar will be created in the same folder level, ready to be executed.

Leave a Reply