Question

Is it possible to make properties in parent pom not overridable by the module pom?

For example:

if module pom says:

<properties>
    <someProperty>some value to be replaced</properties>
</properties>

and parent pom already has it declared as:

<properties>
    <someProperty>strongValue</someProperty>
</properties>

effective module pom should be:

<properties>
    <someProperty>strongValue</someProperty>
</properties>

but it is currently expected to be this:

<properties>
    <someProperty>some value to be replaced</properties>
</properties>

If yes then how to achieve it?

Was it helpful?

Solution

No, you can't. The idea is that if it shouldn't be possible to override a value, don't use a property. If you have no other option, you might want to force it with http://maven.apache.org/enforcer/enforcer-rules/requireProperty.html which will break the build if a property has a different value than expected.

OTHER TIPS

Only way I know to do this for sure is to define the property on the command line, e.g. mvn -DsomeProperty=strongValue <mvn goals/phases here>.

You might experiment with profiles defined in the parent; I suspect that won't help.

A child POM can overwrite the value of a property defined in a parent pom. So it works by just putting a section in the child POM and set the values to desired values.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top