문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top