2

I have only the POM file using which I need to write a script to automatically download all the dependency files and output to custom mentioned path.

I just want to achieve the above using mvn command in command line.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
Dinesh Ravi
  • 1,209
  • 1
  • 17
  • 35

1 Answers1

3

It sounds like you're looking for mvn dependency:copy-dependencies:

dependency:copy-dependencies takes the list of project direct dependencies and optionally transitive dependencies and copies them to a specified location, stripping the version if desired. This goal can also be run from the command line.

From the project root, invoking on the command line

mvn dependency:copy-dependencies -DoutputDirectory=...

will copy all your project direct and transitive dependencies to the specified output directory. If those dependencies are not already in your local Maven repository, they will be downloaded from Maven Central (or from a custom repository).

Tunaki
  • 132,869
  • 46
  • 340
  • 423
  • Is there any way to download the dependencies whose tag is set to true? I can't edit the POM files which is available in 2nd level transitively dependant jars. – Dinesh Ravi Jan 09 '16 at 15:14
  • 1
    @DineshRavi Nope, [optional dependencies](https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html) are meant not to be inherited so Maven will not consider it as a transitive dependency. There's no way around that. – Tunaki Jan 09 '16 at 15:20