Different proxy configurations in different projects

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

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.

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?

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"
}

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