Gradle Tooling API - How to use Gradle wrapper?

1.6k Views Asked by At

I've started using Gradle tooling API and found question: Is there any way to use Gradle wrapper as Gradle installation from Tooling API? I need to ignore any Gradle installation in the system and use Gradle wrapper for target project under Tooling API.

Thanks in advance!

2

There are 2 best solutions below

1
Radim On BEST ANSWER

You don't need to set this. This is the default behavior: tooling API will try to read gradle/wrapper/gradle-wrapper.properties in your project to find appropriate distribution that will be used according to a test in https://github.com/gradle/gradle/blob/7dd276a91d9e22248306584afe04171fd86db529/subprojects/tooling-api/src/test/groovy/org/gradle/tooling/internal/consumer/DistributionFactoryTest.groovy#L44

2
Rene Groeschke On

you could set the installation to use manually and point it to your existing wrapper directory:

GradleConnector connector = GradleConnector.newConnector();
connector.useInstallation(new File("/Users/Rene/.gradle/wrapper/dists/gradle-1.12-all/2apkk7d25miauqf1pdjp1bm0uo/gradle-1.12"));