Gradle Proxy Settings

In this article, we will get to know about Gradle proxy settings, how to configure HTTP/HTTPS proxy for Gradle when you’re behind a corporate proxy. Gradle proxy settings are essential for Gradle to connect to internet to download related dependencies.

1. Gradle proxy settings via gradle.properties file

Gradle proxy settings can be done via gradle.properties file. There are 2 places that we can put the gradle.properties file, either in build’s root directory or in the Gradle user home directory

1.1. The build’s root directory

This is often your project directory in where the build.gradle file is resided. If there is no gradle.properties file here, you can create one. Note that setting proxy by using this file is valid only to this project.

1.2. Gradle user home directory

By default, this directory is: USER_HOME/.gradle

If you’re in Linux system, then below command will take us to that directory:

For example, I am using Ubuntu 16.04, under username: geeksgn, then the Gradle user home directory should be: /home/geeksgn/.gradle

If you’re in Windows system, the Gradle user home directory is often: C:\Users\[YOUR_USERNAME]\.gradle. For example, in my Windows 10 PC, it is: C:\Users\geeksgn\.gradle

Note that the Gradle user home directory can be defined by the “GRADLE_USER_HOME” environment variable; Gradle will use the default if this variable is not set. And setting proxy in this directory will affect to all projects of current user.

1.3. gradle.properties file example

Here is an example of Gradle proxy settings via gradle.properties file.

Note that we have setting both HTTP and HTTPS proxy for Gradle.

2. Summary

We have just gotten through Gradle proxy settings, how to set proxy for Gradle by using gradle.properties file. Here are other links for you reference:

Install Gradle on Ubuntu 16.04 LTS (Xenial Xerus)

Install Gradle on Windows

Gradle Proxy Settings

Where is Gradle Cache Location

Specify The Build File in Gradle

Convert Maven POM File to Gradle Build File

Gradle Tutorials

Refresh or Redownload Dependencies in Gradle

The Gradle Build Environment