Why does tooling API downloads gradle distribution?


I’m using Gradle Tooling API. It probably uses Gradle Wrapper and wants to have downloaded distribution unpacked into ‘~/.gradle/wrapper/dists/gradle-x.y-bin’.

I don’t understand why it is necessary. I already have installed Gradle on my computer and there is also correctly set ‘GRADLE_HOME’ system environment. Problem begins behind proxy. It does not accepts any http/s proxy settings. I’m on OSX and have set bash environments ‘http_proxy’ and ‘https_proxy’; ‘GRADLE_OPTS’ contains ‘-Dhttp.proxyHost=… -Dhttp.proxyPort=… -Dhttps.proxyHost=… -Dhttps.proxyPort=…’; and ‘~/.gradle/gradle.properties’ contains ‘systemProp.http.proxyHost’, ‘systemProp.http.proxyPort’ (as well as ‘https’ settings). But nothing helped.

So my first question is why it is necessary download another Gradle distribution using Gradle Tooling API? And another question/bug is why proxy settings are not used?

Thanks a lot for your answer.

Best regards, -libor

Answer to first question: See class ‘GradleConnector’ for how to configure the tooling API to use a local Gradle installation.

Thanks for pointer.

Is it possible to somehow define following (default) logic of ‘GradleConnector’? “Use Gradle Wrapper if defined in project build gradle file or use $GRADLE_HOME as gradle distribution.”

I could use following way: http://stackoverflow.com/a/26453816/957021 with combination of usage of GRADLE_HOME myself. But I think it would be correct to use specified Wrapper version if specified in ‘build.gradle’.


You could perhaps check if a ‘gradlew(.bat)’ script is present in ‘rootDir’, and if not, use the distribution at ‘GRADLE_HOME’. Whether or not a wrapper task is declared in the build script is not a good indicator. (Recent Gradle versions even declare a wrapper task automatically.)

Thanks for a hint.