Can props from gradle.properties be overwritten with -D parameter?

I have a project with a gradle.properties file that defines a system property for httpProxy.

systemProp.http.proxyHost=proxy

Is it still possible to overwrite that proxy with a -D command line parameter ? I tried it but could not find a way to do so.

Thanks, detlef

-D is maven, within Gradle -P is used.

So, in your case it would be -PsystemProp.http.proxyHost=proxy

Currently, a system property set via ‘gradle.properties’ wins over one passed with ‘-D’. Doesn’t seem right to me, but might be an intentional compromise because the other way around is difficult to implement. We are currently working on related stuff, so maybe we can do something about it. I’ve created GRADLE-2122 to track this.

Oops, I misread the part about system properties. Usually I overwrite props from gradle.properties with -P but I don’t know if this works if it is a system property. Apparently not :slight_smile:

it just works with -Dorg.gradle.project.propertyName=value then you’re property from gradle.properties gets the value overwritten.

sorry. misread you’re intention.

1 Like

Hi, I guess I do something wrong here. If I run

gradle -Dorg.gradle.project.http.proxyHost=anotherProxy.com

and check to debug log statements I still see the proxy that is defined within gradle.properties.

[org.apache.commons.httpclient.HttpConnection] Open connection to fromGradleProperties.com:80

Whats wrong ? thanks, detlef

That’s what this whole thread is about. Properties in ‘gradle.properties’ can not currently be overridden with ‘-D’.