Different proxy configurations in different projects


(Moritz) #1

Hey guys,

in several projects we’re using gradle and for some of them I need to set different proxies. I tried putting a gradle.properties into the projects whose configurations need to be different from the global ~/.gradle/gradle.properties but it doesn’t seem to work. Is there a way to avoid changing the parameters systemProp.http.proxyHost, systemProp.http.proxyPort, systemProp.http.nonProxyHosts in ~/.gradle/gradle.properties all the time?

Cheers,

M


(Peter Niederwieser) #2

Properties in the per-user gradle.properties override properties in the per-build gradle.properties. If you only put proxy settings into per-build gradle.properties, it should work fine. Another solution would be to conditionally set proxy settings in the per-user gradle.properties, for example based on the project’s name.


(Moritz) #3

I tried the first solution and it does not work on my machine (Mac OS). I have a config in ~/.gradle/gradle.properties only defining org.gradle.daemon=true and I guess that should not override the systemProp.http.proxyHost, systemProp.http.proxyPort, systemProp.http.nonProxyHosts parameters, right? Could it be linked to the daemon somehow?


(Peter Niederwieser) #4

This works fine for me:

~/.gradle/gradle.properties:

org.gradle.daemon=true

$projectDir/gradle.properties:

systemProp.http.proxyHost=http://foo/bar

$projectDir/build.gradle

task debug << {
    println System.getProperty("http.proxyHost") // prints "http://foo/bar"
}

(Moritz) #5

Yeah you’re right. My mistake, there was a typo in the project’s gradle.properties :frowning: