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>
Most elements from the parent POM are inherited by its children. Out of these, properties and dependencies comes handy in multi module projects.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With