How to use Maven pom to download jar files only to a specific directory?

By | August 11, 2019

Question

Is there a way to download dependencies from a pom.xml file to a specified folder in java? I’m able to run maven command from java and I got download messages, but I don’t know where maven stores these libraries? How can I download these dependencies to a specific folder?

Solution

Take a look at maven’s dependency plugin, specifically the
copy-dependencies
goal. The usage section describes how to do exactly what you want.

To do it from the command line just do:

$ mvn dependency:copy-dependencies -DoutputDirectory=OUTPUT_DIR

Rate this post

Leave a Reply

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