Book Image

Apache Maven Cookbook

Book Image

Apache Maven Cookbook

Overview of this book

Table of Contents (18 chapters)
Apache Maven Cookbook
About the Author
About the Reviewers

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:

  1. Let us open the demo project that we used in the previous recipe.

  2. Run the following command:

    mvn dependency:copy-dependencies
  3. 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...