Can't override SystemProperty defined in from command line

I have a multimodule build which has a simple task in a subproject

task printSysProp << {
   println "foo is '${}'"

And I define the system property foo in from

As expected, running the task outputs the system property

$ gradle printSysProp
foo is 'Hello from'

Now, I’d like to override the property from command line, but nothing I try will override this.

I’ve tried:

  1. gradle -Dfoo=bar printSysProp
  2. gradle printSysProp
  3. gradle printSysProp

But none change the println (the value is always “Hello from”)
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 but have the option to override from command line.

Thanks for the repro project.

This is a known limitation right now:

Workaround is to try to use project properties instead (depending on what the system properties are used for).

This is definitely not in keeping with what is described in the user guide. I’ve pushed a fix for this which will be included in Gradle 2.12.

Thanks for the quick fix. Unfortunately this won’t come soon enough so I’ll have to use @sterling’s suggestion of a project property for the moment.