Search code examples
mavenmaven-2propertiesmaven-3

Can Maven ignore a missing system property?


If I have the following in my pom file:

<properties>
    <mySystemProperty>${mySystemProperty}</mySystemProperty>
</properties>

When I build using "mvn clean install -DmySystemProperty=someData", it builds successfully. If I build it using "mvn clean install", where I don't need to specify the system property, Maven gives me this error:

Resolving expression: '${mySystemProperty}': Detected the following recursive expression cycle in 'mySystemProperty'

Is there a way to get maven to ignore the missing system property? If not, is there a way to default it?


Solution

  • Solved it. Using the same name for the system variable and maven variable caused the problem. Renaming the system variable fixed the error.

    <properties>
        <mySystemProperty>${sysProperty}</mySystemProperty>
    </properties>