我有一个 maven 项目,其中许多子 pom 的依赖项版本都列在<dependencyManagement>
父 pom 的标签下。这个 pom 树可以有任何深度。
我的问题是,当给出 pom.xml 时,如何使用 java 解决其依赖项的确切(继承)版本?
所需的输出是我们mvn dependency:resolve -DincludeTransitive=false
在 pom.xml 文件上运行时给出的
例如,假设父 pom 在其中定义了以下依赖项<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>
并且子 pom.xml 具有以下依赖项
<dependencies>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-a</artifactId>
</dependency>
<dependency>
<groupId>group-a</groupId>
<artifactId>artifact-b</artifactId>
</dependency>
</dependencies>
如何以编程方式使用 Java检索group-a:artifact-a和group-b:artifact-b的版本?
谢谢。