Copy maven project dependency to specific folder

I am trying to get all the jar needed for a maven project inside a specific folder.

I used the mvn dependency:copy-dependencies command.

It gives me the necessary jar files inside the taget/dependeny folder.

Although I can use move or copy coommand to copy these banks to another directory, is there a way to copy the dependencies in the directory of my choice directly?

+7
maven dependencies
source share
1 answer

You need to use the outputDirectory property to determine the desired location where you want to copy the files.

The following is an example configuration that you would add to your POM:

 <plugins> ... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory> </configuration> </execution> </executions> </plugin> ... </plugins> 

Alternatively, you can pass this configuration directly through the command line:

 mvn -DoutputDirectory=alternativeLocation dependency:copy-dependencies 
+10
source share

All Articles