Downloading dependencies into a folder
Some projects may have a requirement for all the dependencies to be made available, say, in a folder. This could be to archive the dependencies used in a particular version of the build.
How to do it...
Use the following steps to download dependencies in the target/dependency
folder:
Let us open the demo project that we used in the previous recipe.
Run the following command:
mvn dependency:copy-dependencies
See the output in the
target/dependency
folder:
How it works...
The copy-dependencies
goal of the Maven Dependency plugin copies over all the dependencies used in the project, including transitive dependencies, to target/dependency
folder of the project.
There's more...
This goal takes several parameters to handle various use cases, such as copying pom files of the dependencies, copying parent poms, preserving the folder structure of the repository, and so on.
The folder location can be changed by passing the following argument:
mvn dependency:copy-dependencies...