gpt4 book ai didi

java - 在 Maven 中查找定义了属性的位置

转载 作者:行者123 更新时间:2023-12-03 20:20:01 26 4
gpt4 key购买 nike

我目前正在重构各种项目和 git repo 中的大量 pom.xml。
有时,项目 A 中的 pom 将需要在项目 B 中以属性定义的版本定义的 Artifact :

<dependency>
<groupId>com.example</groupId>
<artifactId>artifact-from-b</artifactId>
<version>${version.from.somewhere}</version>
</dependency>

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

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

任何可以帮助我的工具的想法(除了 eclipse,它因某些棘手的属性而失败)?

谢谢 !

最佳答案

这里有一个相关的答案Is there a way to trace origin of a property in maven pom?
建议使用 mvn help:effective-pom -Dverbose=true然后你可以找到类似 com.example.model:2.1.0-SNAPSHOT 的评论.
我试过了,它对我有用。
就我而言,该属性在 com.example.model:2.1.0-SNAPSHOT 的 pom 中定义在第 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 -->

关于java - 在 Maven 中查找定义了属性的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33669562/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com