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.
Use the following steps to download dependencies in the target/dependency
folder:
mvn dependency:copy-dependencies
target/dependency
folder: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.
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 -DoutputDirectory=dependencies
The dependencies will now be copied over to the dependencies
folder instead of the default target/dependency
folder.
The folder structure of the repository can be preserved and the poms of the dependencies can be copied over by running the following command:
mvn dependency:copy-dependencies -Dmdep.copyPom=true Dmdep.useRepositoryLayout=true
The resultant folder structure will be similar to the repository layout as shown in the following screenshot:
3.15.189.199