在maven中查找定义属性的位置

pol*_*kho 5 java maven

我目前正在各种项目和 git repo 中重构大量 pom.xml。有时,项目 A 中的 pom 需要项目 B 中定义的工件(其版本由属性定义):

<dependency>
    <groupId>com.example</groupId>
    <artifactId>artifact-from-b</artifactId>
    <version>${version.from.somewhere}</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

有时,版本属性没有在 pom 本身或其父 pom 中明确定义。它可以隐藏在父母的父母的父母中......

我目前正在尝试找到一种方法来轻松解析 ${version.from.somewhere} 等属性并找到它的定义位置。

有什么工具可以帮助我(除了 eclipse 之外,它因某些棘手的属性而失败)吗?

谢谢 !

use*_*322 5

这里有一个相关的答案Is there a way to track origin of a property in maven pom?

建议使用mvn help:effective-pom -Dverbose=true然后你可以找到类似的评论com.example.model:2.1.0-SNAPSHOT

我尝试过,它对我有用。

就我而言,该属性是在 pom 的com.example.model:2.1.0-SNAPSHOT第 407 行中定义的

<dependency>
          <groupId>com.example</groupId>  <!-- com.example.model:2.1.0-SNAPSHOT, line 405 -->
          <artifactId>model</artifactId>  <!-- com.example.model:2.1.0-SNAPSHOT, line 406 -->
          <version>1.0.6</version>  <!-- com.example.model:2.1.0-SNAPSHOT, line 407 -->
Run Code Online (Sandbox Code Playgroud)