Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Maven support properties inheritance?

Tags:

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.

like image 972
Guillaume Belrose Avatar asked Oct 05 '10 12:10

Guillaume Belrose


People also ask

How does Maven inherit?

All Maven POMs inherit values from a parent POM. If a POM does not specify a direct parent using the parent element, that POM will inherit values from the Super POM. Project Inheritance shows the parent element of project-a which inherits the POM defined by the a-parent project.

Is it possible to have inheritance between POM xml?

Maven parent POM (or super POM) is used to structure the project to avoid redundancies or duplicate configurations using inheritance between pom files. It helps in easy maintenance in long term.

Does Maven support multi project build?

As seen in the introduction to the POM, Maven supports project aggregation in addition to project inheritance. This section outlines how Maven processes projects with multiple modules, and how you can work with them more effectively.

What is the use of properties in Maven?

Maven properties are value placeholders, like properties in Ant. Their values are accessible anywhere within a POM by using the notation ${X}, where X is the property. Or they can be used by plugins as default values, for example: In your case you have defined properties as version of java.


1 Answers

Yes, they are inherited by children poms. Did it not work when you tried it out?

like image 125
wds Avatar answered Sep 30 '22 18:09

wds