Home > Blockchain >  How to use pom.xml properties from different pom.xml
How to use pom.xml properties from different pom.xml

Time:03-25

I have multi-module project with parent pom.xml I want to use properties not from the parent pom

parent:

<properties> 
   <dev.version>1.1<dev.version/>  
</properties>

different module:

<properties>    
   <dev.version>1.2<dev.version/>  
</properties>

how to get properties not from the parent?

my module:

<properties>
   <dev.version>${different_module.dev.version}<dev.version/>
</properties>

 <dependency>
    <groupId>...</groupId>
    <artifactId>...</artifactId>
    <version>${dev.version}</version>
 </dependency>

i tried used to mojohaus properties-maven-plugin but apparently it needs a file with properties and not pom

CodePudding user response:

Properties are inherited, in your child pom with current implementation you are overwriting the property dev.version and with calling the property you will get the overwritten value, so one practice could be change the property name in you reactor (parent) pom and access it with new name(pointer) in child pom's.

  • Is there other way to not overwrite ?

No, you can't. The idea is that if it shouldn't be possible to override a value, don't use a property.

  • Related