ziggy
ziggy

Reputation: 15876

Maven - Access properties on parent pom from a child pom

In a multi module project structure as

myApp
|-moduleA
|---pom.xml
|-moduleB
|---pom.xml
|-pom.xml

If i have the following properties in the parent.pom

  <properties>
   <moduleA.version>4.67</moduleA.version>
   <moduleB.version>4.68</moduleB.version>
  </properties>  

How can i access the properties in the parent pom from any of the child poms? I tried this on the child pom but it didnt work.

  <groupId>com.test</groupId>
  <artifactId>moduleA</artifactId>
  <version>${moduleA.version}</version>

Upvotes: 4

Views: 12722

Answers (2)

khmarbaise
khmarbaise

Reputation: 97567

If you have a real multi-module build you should never define the modules to have different versions. They should have the same version which make releasing possible and other things as well. Otherwise you should not use the multi-module setup than use simple single modules which are separated.

Upvotes: 4

MaDa
MaDa

Reputation: 10772

This should work. One possible reason I can think of is that perhaps you don't actually inherit the pom where these properties are defined (i.e. it's not defined as your <parent> directly or indirectly), but you only have a main pom that aggregates your projects. It's a guess, though.

Upvotes: 2

Related Questions