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

4.5k views Asked by At

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.

3

There are 3 answers

0
Yogesh_D On

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

1
prunge On

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.

0
khmarbaise On

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.