0

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

  • In particular for dependencies I recommend to define the dependency in a dependencyManagement in the parent of your multi module project...than you don't need a property in the childs...because you can omit the version tag in the childs... – khmarbaise Mar 25 '22 at 07:30

1 Answers1

0

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.

Lunatic
  • 1,519
  • 8
  • 24
  • Unfortunately, I can't do that, maybe there are some plugins? `different module` is just a pom/bom – Aleksey Bakharev Mar 25 '22 at 07:38
  • @AlekseyBakharev i added your new question answer as well, see more in here https://stackoverflow.com/q/18641504/15758781 – Lunatic Mar 25 '22 at 07:41
  • @AlekseyBakharev also, please consider to accept the provided solution as answer if it satisfied the requirement or feel free leave comment . – Lunatic Mar 25 '22 at 07:57
  • in the link provided is not exactly the same question-answer. Let's clarify, it turns out that if there is a parent pom, it will not work to use properties with the same name from another module (bom) ? – Aleksey Bakharev Mar 25 '22 at 08:09
  • @AlekseyBakharev yes because of inheritancy – Lunatic Mar 25 '22 at 08:11