Overriding module properties from parent POM in Maven

zacheusz picture zacheusz · Sep 5, 2013 · Viewed 18k times · Source

Is it possible to override module properties from parent pom without changing the module pom?

For example:

module pom (I can't change it at all):

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

parent pom:

<properties>
    <someProperty>strongValue</someProperty> <!-- some magic here -->
</properties>

effective module pom:

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

If yes then how to achieve it?

Answer

user944849 picture user944849 · Sep 5, 2013

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.