CuriousMind
CuriousMind

Reputation: 15798

Maven -- is there a command to download the parent poms of all dependency jars?

I know we can download the dependency jars... but can we download the parent poms of all dependency jars?

For example Project A brings in library B as dependency, but library B has parent pom C.xml.

I want to find a command that downloads all pom.xml in Bs and C.xml.

ideally if C.xml has another parent pom D.xml, I want to download that too.

Upvotes: 5

Views: 4791

Answers (3)

khmarbaise
khmarbaise

Reputation: 97409

The simplest solution is to use

mvn org.apache.maven.plugins:maven-dependency-plugin:2.9:resolve

or more short:

mvn dependency:resolve

it will resolve all dependencies incl. the pom's etc. Afterwards you can build with this repository offlline. They will be downloaded into the local repository. If you like to have those artifacts incl. their poms into a particular directory than you have to use the suggestions made by @prunge.

Upvotes: 1

Yogesh_D
Yogesh_D

Reputation: 18764

The answer by prunge shows you have to download them using dependency plugin. If you are just curious to see those poms, maven does download them to the local cached copy of the repo. Just go to .m2/repoistory and you will find them as -.pom. The file is name as .pom and is actually the pom.xml for that particular artifact

Upvotes: 3

prunge
prunge

Reputation: 23248

Maven dependency plugin with add parent POMs option.

mvn dependency:copy-dependencies -Dmdep.addParentPoms=true -Dmdep.copyPom=true

If that doesn't work because of Maven using an older version of the dependency plugin (you need 2.8 or later for the addParentPoms option), use the latest version explicitly:

mvn org.apache.maven.plugins:maven-dependency-plugin:2.9:copy-dependencies -Dmdep.addParentPoms=true -Dmdep.copyPom=true

These commands download dependencies (including transitive dependencies), their POMs and all the parent POMs recursively.

Upvotes: 3

Related Questions