I have a multimodule build which has a simple task in a subproject
task printSysProp << {
println "foo is '${System.properties.foo}'"
}
And I define the system property foo in gradle.properties
systemProp.foo=Hello from gradle.properties
As expected, running the task outputs the system property
$ gradle printSysProp
:subproject:printSysProp
foo is 'Hello from gradle.properties'
Now, I’d like to override the property from command line, but nothing I try will override this.
I’ve tried:
gradle -Dfoo=bar printSysProp
gradle -DsystemProp.foo=bar printSysProp
gradle -PsystemProp.foo=bar printSysProp
But none change the println (the value is always “Hello from gradle.properties”)
I’m using Gradle 2.11
I have created a project demonstrating the issue here. I’d like a way to specify a default in gradle.properties but have the option to override from command line.