Find in maven where a property is defined

时间:2015-11-12 10:40:24

标签: java maven

I'm currently refactoring lots of pom.xml in various projects and git repo. Sometimes, a pom in a project A will require an artifact defined in a project B in a version defined by a property :

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

Sometimes, the version property is not obviously defined in the pom itself or its parent pom. It can be hidden in a parent's parent's parent...

I'm currently trying to find a way to resolve easily properties like ${version.from.somewhere} and find where it is defined.

Any idea of any tool that can help me (apart from eclipse, which fails for some tricky properties) ?

Thanks !

1 个答案:

答案 0 :(得分:0)

这里有一个相关的答案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 -->