caneru
caneru

Reputation: 461

How to set proxy server for gradle?

I need to set a proxy server to be able to use gradle from my company's network to download project dependencies.I tried setting the proxy for shell, but it didn't work, so i assume it is because of the commands, gradle using to download these dependencies, does not use http_proxy environment variable.

Which commands (like wget, curl) does gradle use when downloading project dependencies? How can i check these commands? I tried both --info and --debug options, but it only says for each file something like;

Download https://jcenter.bintray.com/com/android/tools/lint/lint/25.1.0/lint-25.1.0.pom

Upvotes: 13

Views: 60844

Answers (2)

Hritik Agrahari
Hritik Agrahari

Reputation: 11

Set up the Android Studio proxy Android Studio supports HTTP proxy settings so you can run Android Studio behind a firewall or secure network. To set the HTTP proxy settings in Android Studio:

  1. From the menu bar, click File > Settings (on macOS, click Android Studio > Preferences).
  2. In the left pane, click Appearance & Behavior > System Settings > HTTP Proxy. The HTTP Proxy page appears.
  3. Select Auto-detect proxy settings to use an automatic proxy configuration URL for the proxy settings or Manual proxy configuration to enter each of the settings yourself.
  4. Click Apply or OK for your changes to take effect.

Upvotes: 0

JBirdVegas
JBirdVegas

Reputation: 11403

Gradle has it's own dependency management system similar to maven. I think parts of the gradle publish plugin are backed by maven in some way (not verified). Regardless you shouldn't have to worry about that level of depth, gradle will handle it. Your problem is setting up the proxy. You just need to set some variables in $projectDir/gradle.properties, example:

#http proxy setup
systemProp.http.proxyHost=www.somehost.org
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=userid
systemProp.http.proxyPassword=password
systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost

#https proxy setup
systemProp.https.proxyHost=www.somehost.org
systemProp.https.proxyPort=8080
systemProp.https.proxyUser=userid
systemProp.https.proxyPassword=password
systemProp.https.nonProxyHosts=*.nonproxyrepos.com|localhost

reference: https://docs.gradle.org/current/userguide/build_environment.html#sec:accessing_the_web_via_a_proxy

Upvotes: 50

Related Questions