gradle Gradle Wrapper Using the Gradle Wrapper behind a proxy


Example

The first time a user runs a project's gradlew, it should be realized that it will do two key things:

  1. Check to see if the version of the gradle used by the wrapper is already in ~/.gradle/wrapper/dists
  2. If not, download the archive of the version from the internet

If you're in an environment that requires all external traffic to go through a proxy, step two is going to fail (unless it's a transparent proxy environment). As a result, you need to ensure your have the JVM proxy parameters set.

For example, if you have a basic proxy setup with no authentication, simply set the environment variable JAVA_OPTS or GRADLE_OPTS with:

-Dhttps.proxyPort=<proxy_port> -Dhttps.proxyHost=<hostname>

So a completed example on windows would be:

set JAVA_OPTS=-Dhttps.proxyPort=8080 -Dhttps.proxyHost=myproxy.mycompany.com

If however your environment also requires authentication, then you'll also want to review your other options at https://docs.oracle.com/javase/8/docs/api/java/net/doc-files/net-properties.html.

NOTE: This proxy configuration is in addition to any proxy configuration for your dependency repository access.