Does Maven support properties inheritance?

Viewed 10236

Let's say I have a property foo defined in my parent POM. Is it possible to access the "foo" propery in any of the children?

To give you a bit of context, I am working on a multi-module maven project with inheritance.

I did search the web and some forums for a while and could not find the answer.

Many thanks in advance.

2 Answers

Yes, properties are inherited from parent pom. You can access them via ${property.name}

Here is an example where we inherit the property jackson.version from the parent pom.

PARENT POM

<!-- We define the property here -->
<properties>
    <jackson.version>2.9.0</jackson.version>
</properties>

CHILD POM

<plugin>
    <groupId>com.fasterxml.jackson.datatype</groupId>
    <artifactId>jackson-datatype-json-org</artifactId>
    <!-- We reference the property in the child pom -->
    <version>${jackson.version}</version>
</plugin>
Related