java - Gradle proxy configuration

ID : 20213

viewed : 29

Tags : javaproxyactive-directorywindows-server-2008gradlejava

Top 5 Answer for java - Gradle proxy configuration

vote vote


Refinement over Daniel's response:

HTTP Only Proxy configuration

gradlew -Dhttp.proxyHost= -Dhttp.proxyPort=3128 "-Dhttp.nonProxyHosts=*|localhost"

HTTPS Only Proxy configuration

gradlew -Dhttps.proxyHost= -Dhttps.proxyPort=3129 "-Dhttp.nonProxyHosts=*|localhost"

Both HTTP and HTTPS Proxy configuration

gradlew -Dhttp.proxyHost= -Dhttp.proxyPort=3128 -Dhttps.proxyHost= -Dhttps.proxyPort=3129 "-Dhttp.nonProxyHosts=*|localhost"

Proxy configuration with user and password

gradlew -Dhttp.proxyHost= -Dhttp.proxyPort=3128 - Dhttps.proxyHost= -Dhttps.proxyPort=3129 -Dhttps.proxyUser=user -Dhttps.proxyPassword=pass -Dhttp.proxyUser=user -Dhttp.proxyPassword=pass|

worked for me (with in either homedir or project dir, build was still failing). Thanks for pointing the issue at gradle that gave this workaround. See reference doc at

Update You can also put these properties into (see:

vote vote


This is my, please note those HTTPS portion

systemProp.http.proxyHost= systemProp.http.proxyPort=8118 systemProp.https.proxyHost= systemProp.https.proxyPort=8118 
vote vote


In my build.gradle I have the following task, which uses the usual linux proxy settings, HTTP_PROXY and HTTPS_PROXY, from the shell env:

task setHttpProxyFromEnv {     def map = ['HTTP_PROXY': 'http', 'HTTPS_PROXY': 'https']     for (e in System.getenv()) {         def key = e.key.toUpperCase()         if (key in map) {             def base = map[key]             def url = e.value.toURL()             println " - systemProp.${base}.proxy=${}:${url.port}"             System.setProperty("${base}.proxyHost",             System.setProperty("${base}.proxyPort", url.port.toString())         }     } }  build.dependsOn setHttpProxyFromEnv 
vote vote


For me, works adding this configuration in the file of the project, where the build.gradle file is:

systemProp.http.proxyHost=proxyURL systemProp.http.proxyPort=proxyPort systemProp.http.proxyUser=USER systemProp.http.proxyPassword=PASSWORD systemProp.https.proxyHost=proxyUrl  systemProp.https.proxyPort=proxyPort systemProp.https.proxyUser=USER systemProp.https.proxyPassword=PASSWORD 

Where : proxyUrl is the url of the proxy server (http://.....)

proxyPort is the port (usually 8080)

USER is my domain user

PASSWORD, my password

In this case, the proxy for http and https is the same

vote vote


Check out at c:\Users\your username\.gradle\

systemProp.http.proxyHost=<proxy host> systemProp.http.proxyPort=<proxy port> systemProp.http.proxyUser=<proxy user> systemProp.http.proxyPassword=<proxy password> systemProp.http.nonProxyHosts=<csv of exceptions> systemProp.https.proxyHost=<proxy host> systemProp.https.proxyPort=<proxy port> systemProp.https.proxyUser=<proxy user> systemProp.https.proxyPassword=<proxy password> systemProp.https.nonProxyHosts=<csv of exceptions seperated by | > 

Top 3 video Explaining java - Gradle proxy configuration