Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inheriting properties from parent pom

Tags:

Is there a way to inherit properties from parent pom. E.g: I want to replace ${publish.dir} in child pom with the value from parent pom.

parent pom:

<properties> <publish.dir>/tmp/publish</publish.dir> </properties>

child pom:

<outputDirectory>${publish.dir}/dev</outputDirectory>

like image 240
user1006139 Avatar asked Oct 20 '11 22:10

user1006139


People also ask

Are properties inherited from parent pom?

Most elements from the parent POM are inherited by its children. Out of these, properties and dependencies comes handy in multi module projects.

What do child POM inherit from the parent pom?

Now child POM need to refer the parent POM using parent tag and specifying groupId/artifactId/version attributes. This pom file will inherit all properties and dependencies from parent POM and additionally can include extra sub-project specific dependencies as well.

How do you define parent pom?

A parent pom. xml file (or super POM) in Maven is used to structure the project in order to avoid redundancies and duplicate configurations by using an inheritance between different pom. xml files. If any dependency or properties are configured in both - parent and child - pom.

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.


1 Answers

There is no way not to inherit properties from a parent POM. Properties defined in a parent are visible in the child.

However. outputDirectory is relatively special part of the POM data model. Inherited properties won't work for that. I'm sorry that it took me so long for the appropriate part of my brain to turn on. I think that you might be out of luck, or might need to specify the output to specific plugins.

like image 66
bmargulies Avatar answered Sep 27 '22 19:09

bmargulies