Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Global gradle proxy settings?

Tags:

java

gradle

Is there any way to simply set up a global, system-wide proxy for gradle?

Yes, I know there is a systemProp.http.proxyHost, ...etc settings in the current gradle.properties file, but it works only in the actual project. But

  • I won't set it up in every gradle project
  • and I won't change the source code of a project because of my local network configuration.

So, is there any "global gradle.properties" file or so?

like image 921
peterh Avatar asked Oct 23 '14 08:10

peterh


People also ask

Where is gradle proxy set?

Android plugin for Gradle HTTP proxy settings gradle file as required for each application module. For project-wide HTTP proxy settings, set the proxy settings in the gradle/gradle. properties file.

How do you fix you may need to adjust the proxy settings in gradle?

On your android studio goto file -- settings -- Build, Execution, Deployment --Build Tools -- Gradle and choose Use local gradle distribution, in the gradle home locate your gradle folder and click apply. Then click okay. This solved the problem for me.


2 Answers

Yes it seems possible. See here, especially:

We can define a gradle.properties file and set the property in this file. We can place the file in our project directory or in the <USER_HOME>/.gradle directory. The properties defined in the property file in our home directory take precedence over the properties defined in the file in our project directory. As a bonus we can also define system properties in a gradle.properties file, we only have to prefix the property name with systemProp..

The gradle.properties files can be found at the following paths:

# windows gradle file %userprofile%\.gradle\gradle.properties  # linux gradle file ~/.gradle/gradle.properties  
like image 183
Opal Avatar answered Oct 05 '22 22:10

Opal


Copy & paste:

systemProp.http.proxyHost=127.0.0.1 systemProp.http.proxyPort=8080 systemProp.https.proxyHost=127.0.0.1 systemProp.https.proxyPort=8080 

to gradle global config = current user's gradle.properties

  • Linux/Mac/Unices: $HOME/.gradle/gradle.properties
    • eg: /Users/limao/.gradle/gradle.properties
  • Windows: %userprofile%\.gradle\gradle.properties

More details refer official doc Accessing the web through a HTTP proxy

Thanks to @Opal's answer, @fty4

like image 31
serv-inc Avatar answered Oct 05 '22 21:10

serv-inc