Gradle proxy configuration
Configure Gradle to use a proxy by setting system properties in gradle.properties
:
For authentication with the proxy, include:
These settings instruct Gradle to direct all HTTP and HTTPS traffic through the given proxy server, using the provided username and password for authenticated proxies.
Mastering specials: characters and exceptions
For special characters in the username or password, encode them appropriately:
These settings handle Active Directory usernames including backslashes, and passwords with special characters like dollar signs.
To bypass the proxy for specific hosts, use the nonProxyHosts
property:
These establishments (domains or IP ranges) get a VIP, direct-access pass, bypassing the proxy.
Tweaking the nuts and bolts
Custom setup for individual projects
For project-specific proxy configurations, place a gradle.properties
file in the root directory:
Proxy via environment variables
Proxy configuration can be drawn from environment variables by creating a task in build.gradle
:
Ensure this task runs before any others to set the proxy right out the front door.
Fixing common HTTP issues: 407, 502
HTTP errors like 407 and 502 often mean your proxy setup has hiccupped. Double-check your proxyHost
, proxyPort
, proxyUser
, and proxyPassword
in the gradle.properties
file. If Sheriff IT gives your credentials the nod, you're all set.
Settings, checks, and fine tunes
Separate proxy for Gradle Wrapper
Sometimes, the Gradle wrapper's whims may be different. In such cases, proxy settings are stated in gradle-wrapper.properties
:
Be sure these abide by the Gradle wrapper's tastes & your network's rules.
Proxy settings: Gradle & system environment
To avoid a proxy tug-of-war and build failures, have your system's environment proxy settings match Gradle's:
Make these match the gradle.properties
settings for seamless navigation.
Proxies in complex setups
For sophisticated setups needing multiple proxies or dynamic switching, write custom tasks or rope in network admins to raft through the minefield.
Was this article helpful?