I have a maven project where many of the version of child pom's dependencies are listed under <dependencyManagement>
tag of the parent pom. This pom tree can have any depth.
My problem is, when a pom.xml is given how can I resolve the exact(inherited) version of it's dependencies using java?
The desired output is what is given when we run mvn dependency:resolve -DincludeTransitive=false
on a pom.xml file
For an example, let's say parent pom has following dependencies defined in it under <dependencyManagement>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-a</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-b</artifactId>
<version>1.0</version>
<type>bar</type>
<scope>runtime</scope>
</dependency>
</dependencies>
</dependencyManagement>
and child pom.xml has following dependencies
<dependencies>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-a</artifactId>
</dependency>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-b</artifactId>
</dependency>
</dependencies>
How can i retrieve the versions of group-a:artifact-a and group-b:artifact-b using Java programmatically?
Thanks.