Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find in maven where a property is defined

Tags:

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 !

like image 709
polhomarkho Avatar asked Oct 30 '22 15:10

polhomarkho


1 Answers

There is a related answer here Is there a way to trace origin of a property in maven pom?

That suggest using mvn help:effective-pom -Dverbose=true then you can find comments like com.example.model:2.1.0-SNAPSHOT.

I tried it and it worked for me.

In my case, the property is defined in the pom of com.example.model:2.1.0-SNAPSHOT in line 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 -->
like image 75
user454322 Avatar answered Nov 15 '22 14:11

user454322