Download all project dependencies to a folder with Maven

Some days ago at work I had a new requirement, upload all our deliverable packages (*.jar, *.war) to a new service for a security analysis.

The first solution was to upload artifact after its build on the continuous integration server. However this was not a good solution as all the artifacts must be uploaded at the same time.

After some research I’ve found the maven-dependency-plugin. A very helpful plugin to manage all the dependencies defined in a pom.xml.

It has lots of options but the one useful for this task is copy-dependencies. It downloads all the dependencies defined on a project to a folder.

Here is the resulting pom.xml that would place the artifacts on the ${}/dependency by default. See the comments below in the code:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi=""


    <!-- Define repositories -->

    <!-- Define identification of this artifact -->


    <!-- Dependencies to be downloaded, RELEASES or SNAPSHOTS -->

                <!-- Our helpful plugin -->
                            <!-- Remove classfier and version from the target files. -->

By executing mvn package on the pom.xml folder, we would have the files on the destination folder (./target/dependency/):

  • goodproject.jar
  • webproject.war
  • application.war

After giving this solution, I had a great ovation from the team.

Citizen Kane applause