Gradlew behind the proxy

I have a sample from Gaelyk (called Bloogie) and it uses gradlew.

I am for the proxy.

I read gradle docs and found this:

gradle.properties

systemProp.http.proxyHost=www.somehost.org systemProp.http.proxyPort=8080 systemProp.http.proxyUser=userid systemProp.http.proxyPassword=password 

But I have no idea how to put this information in a gradlew wrapper. Any idea?

+48
gradle gaelyk
Jan 20 '12 at 9:10
source share
17 answers

All you have to do is create a file called gradle.properties (with the above properties) and put it in your gradle user home directory (which is USER_HOME/.gradle ) OR in the project directory.

Gradle (wrapper too !!!) automatically selects gradle.properties files if they are in the user's home directory or in project directories.

For more information, read the Gradle User Guide, especially in section 12.3: Accessing the Network through a Proxy Server

+64
Jan 24 2018-12-12T00:
source share

If you need https access behind a proxy server, also consider defining the same set of properties for systemProp.https.

 systemProp.https.proxyHost=www.somehost.org systemProp.https.proxyPort=8080 

See Unable to create an Android application using crashlytics for VPN and proxy for more information.

+40
Mar 03 '14 at 9:39
source share

Use this in the prompt bar:

 gradle -Dhttp.proxyHost=*** -Dhttp.proxyPort=*** -Dhttp.proxyUser=**** -Dhttp.proxyPassword=**** 

It works here!

+19
Dec 15 '14 at 18:58
source share

Add the following to your gradle.properties file and to your gradle/wrapper/gradle-wrapper.properties if you download the shell through a proxy

If you want to set these properties globally, add them to USER_HOME/.gradle/gradle.properties file

 ## Proxy setup systemProp.proxySet=true systemProp.http.keepAlive=true systemProp.http.proxyHost=host systemProp.http.proxyPort=port systemProp.http.proxyUser=username systemProp.http.proxyPassword=password systemProp.http.nonProxyHosts=local.net|some.host.com systemProp.https.keepAlive=true systemProp.https.proxyHost=host systemProp.https.proxyPort=port systemProp.https.proxyUser=username systemProp.https.proxyPassword=password systemProp.https.nonProxyHosts=local.net|some.host.com ## end of proxy setup 
+14
Feb 27 '17 at 16:37
source share

I could not get the proxy property to work until I installed the https proxy:

 systemProp.https.proxyHost=www.somehost.org systemProp.https.proxyPort=8080 

However, I had to use the http property for the username and password:

 systemProp.http.proxyUser=userid systemProp.http.proxyPassword=password 
+9
Dec 29 '15 at 10:01
source share

This issue with Gradle Wrapper has been fixed with Gradle 1.0-milestone-8. Take a picture.

+6
Feb 26 2018-12-12T00:
source share

To add more nuances, for my case, when I have several gradle.properties files both in USER_HOME / .gradle and in the project root, I encountered a 407 authentication request error with the following log:

CONNECT refused by proxy: HTTP/1.1 407 authenticationrequired

This caused my systemProp.https.proxyPassword and systemProp.http.proxyPassword empty in the gradle.properties file under USER_HOME / .gradle, and the file in gradle.properties under the project root was password information.

I don’t know the exact reason, but when I delete one gradle.properties in the root of the project and save the file in USER_HOME / .gradle, my case is resolved.

+3
Apr 24 '18 at 6:30
source share

I had the same problem and the first thing I did was create gradle.properties. I did not have a file of type file, so I have to create it with the following contents:

 systemProp.http.proxyHost=proxy systemProp.http.proxyPort=port systemProp.http.nonProxyHosts=domainname|localhost systemProp.https.proxyHost=proxy systemProp.https.proxyPort=port systemProp.https.nonProxyHosts=domainname|localhost 

When I added them, the gradlew command works properly for the corporate proxy. I hope this can be helpful.

+2
Sep 19 '17 at 11:34 on
source share

after this JDK update, I could not use gradlew again for the proxy. and finally I found that the JDK turned off default authentication for HTTPS tunneling by default. so I have to add this property for gradle.properties in addition to the proxy settings

 systemProp.jdk.http.auth.tunneling.disabledSchemes="" 

I hope this will be useful for those struggling with the same problem.

+2
Feb 20 '18 at 4:44
source share

It was discovered that reading properties from gradle.properties might be wrong. In case the line contains a space, gradle cannot find the proxy. check your proxy file and cut the space at the end of the line. May I help

+1
Nov 25 '15 at 8:15
source share

At first it didn't work for me.
In my case, I created what I thought was the USER_HOME / .gradle / gradle.properties file, but eventually the gradle.properties.txt file appeared.

In the terminal window, the ls command displays the full file names in the .gradle folder.

Then mv gradle.properties.txt gradle.properties

+1
Nov 22 '17 at 17:48
source share

I have the same problem with a proxy server when working with a Cordova project.

To fix the problem, I created a new gradle.properties file in the android folder of my Cordova project ( hello/platforms/android ) and added the code from your question

 systemProp.http.proxyHost=proxy.yourproxysite.com systemProp.http.proxyPort=8080 systemProp.http.proxyUser=yourusername systemProp.http.proxyPassword=password 
0
Jan 6 '17 at 11:00
source share

Setting up an SSl proxy worked for me.

 systemProp.http.proxyHost=proxy.yourproxysite.com systemProp.http.proxyPort=8080 systemProp.https.proxyHost=proxy.yourproxysite.com systemProp.https.proxyPort=8080 
0
Feb 08 '17 at 11:46 on
source share

Fragmented answer from the linked branch below. This shows how to do this more programmatically. Hope help

 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] //Get proxyHost,port, username, and password from http system properties // in the format http://username:password@proxyhost:proxyport def (val1,val2) = e.value.tokenize( '@' ) def (val3,val4) = val1.tokenize( '//' ) def(userName, password) = val4.tokenize(':') def url = e.value.toURL() //println " - systemProp.${base}.proxy=${url.host}:${url.port}" System.setProperty("${base}.proxyHost", url.host.toString()) System.setProperty("${base}.proxyPort", url.port.toString()) System.setProperty("${base}.proxyUser", userName.toString()) System.setProperty("${base}.proxyPassword", password.toString()) } } } 

See this topic for more.

0
Mar 26 '18 at 18:26
source share

After long attempts with this and banging my head against the wall, because nothing in my system used a proxy: it turned out that my copy of ** Android Emulator ** itself secretly / silently set the proxy for me through Android Emulator> Settings> Proxy server and applied these settings while playing with him a week earlier to fix the problem with Expo.

If anyone has this problem, make sure you check 100% to make sure that the proxy user settings are not really used with: ./gradlew installDebug --info --debug --stacktrace and search proxyHost over the weekend log data to make sure of this. It could be your emulator.

0
May 21 '18 at 15:44
source share

You should add the following configuration to gradle.configuration These are the proxy settings that you need to configure if you are working with a proxy.

Source: ( https://docs.gradle.org/current/userguide/build_environment.html#sec:accessing_the_web_via_a_proxy )

And don’t add "http.//or/humanhttps:min to systemProp.http.proxyHost only" www.host.com β€œ. Also comment out systemProp.http.proxyUser or proxypassword if you do not need to log in to the proxy.

 systemProp.proxySet=true systemProp.http.keepAlive=true systemProp.http.proxyHost=www.host.com systemProp.http.proxyPort=port systemProp.http.proxyUser=username_ifneeded systemProp.http.proxyPassword=password_needed systemProp.http.nonProxyHosts=local.net|some.host.com systemProp.https.keepAlive=true systemProp.https.proxyHost=host systemProp.https.proxyPort=port systemProp.https.proxyUser=username_ifneeded systemProp.https.proxyPassword=password_ifneeded systemProp.https.nonProxyHosts=local.net|some.host.com 
0
Jul 17 '19 at 13:41
source share
 systemProp.http.proxyUser=userId systemProp.http.proxyPassword=password 

same with https ......

-3
May 23 '16 at 23:54
source share



All Articles