Skip to content

Instantly share code, notes, and snippets.

@mohitsethi
Created November 24, 2015 09:05
Show Gist options
  • Select an option

  • Save mohitsethi/1220bd9c0c7d2d317945 to your computer and use it in GitHub Desktop.

Select an option

Save mohitsethi/1220bd9c0c7d2d317945 to your computer and use it in GitHub Desktop.
gradle proxy
task setHttpProxyFromEnv {
def map = ['HTTP_PROXY': 'http', 'HTTPS_PROXY': 'https']
for (e in System.getenv()) {
def key = e.key.toUpperCase()
if (key in map) {
def base = map[key]
def url = e.value.toURL()
println " - systemProp.${base}.proxy=${url.host}:${url.port}"
System.setProperty("${base}.proxyHost", url.host.toString())
System.setProperty("${base}.proxyPort", url.port.toString())
}
}
}
build.dependsOn setHttpProxyFromEnv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment