Gradle multiple versions OF GRADLE
Asked Answered
B

1

16

For the sake of clarity: this is NOT about multiple versions of dependencies, it's about multiple versions of Gradle's own jars.

I thought this might have the answer... but there aren't any!

This is Gradle 2.14, with a Windows 10 OS.

I found that gradle was constantly building a new directory under the ".gradle\" directory for this project: alongside the legitimate "2.14\" directory it kept building a "2.2.1\" directory.

I looked under my directory where Gradle is installed: and puzzlingly I found multiple versions of Gradle's jar files: not only 2.14, but 2.13, 1.7, and yes, 2.2.1..

So I decided to manually delete the 2.2.1. jars. It stopped building the "spurious" 2.2.1 directory.

Can someone tell me how Gradle decides which version of itself it is using? I'd really like to get rid of those non-2.14 jars and find a way to prevent other versions creeping back in somehow!

Brieta answered 12/2, 2017 at 14:3 Comment(2)
The gradle docs recommend keeping the gradle wrapper alongside the source code which guarantees that users of the project always work with the intended version. You can initialize it with executing gradle wrapper. After that, the IDE can be configured to always use the gradle wrapper or use gradlew on the console.Halfpint
Thanks for that pointer. I shall read that carefully.Brieta
F
22

Can someone tell me how Gradle decides which version of itself it is using ?

This depends on how you invoke gradle.

Method 1. A gradle command will invoke the version of gradle which is in your GRADLE_HOME path.

Method 2. Using gradle wrapper

A gradlew command will invoke the version of gradle which is configured in your project's gradle\wrapper\gradle-wrapper.properties file if it exists already. If its not, you can create it by gradle wrapper --gradle-version 3.3. Now when you use gradlew , it will always use gradle version 3.3.

The use of gradle wrapper is recommended so that you can consistently reproduce the same build in different machines where the installed gradle versions might be different or even on machines where gradle is not installed, because gradlew.bat and gradlew will be used on windows and linux respectively for bootstrapping the build.

The reason you found multiple version of gradle in your .gradle directory might be because previously you might have tried to build with those versions for gradle.

Francophobe answered 31/3, 2017 at 18:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.