Can someone tell me how Gradle decides which version it uses?
It depends on how you call gradle.
Method 1 .. The gradle command will display the version of Gradle that is in the GRADLE_HOME path.
Method 2. Using gradle wrapper
Command
A gradlew will invoke the version of Gradle that is configured in the gradle\wrapper\gradle-wrapper.properties project file if it already exists. If not, you can create it on gradle wrapper --gradle-version 3.3 . Now when you use gradlew , it will always use Gradle version 3.3.
It is recommended that you use the Gradle shell so that you can play the same assembly sequentially on different machines where the installed versions of Gradle may differ, or even on machines where Gradle is not installed, because gradlew.bat and gradlew will be used for windows and linux respectively for bootstrap assembly.
The reason you found several versions of Gradle in your .gradle directory might be because you might have previously tried to build gradle with these versions.
source share