Gradle has a built-in task called wrapper
that ./gradlew tasks
describes with:
wrapper - Generates Gradle wrapper files.
Not terribly descriptive, but it is quite a useful task for the following cases:
Updating to a different version of Gradle
./gradlew wrapper --gradle-version 8.12
This will update your gradle/gradle/gradle-wrapper.properties
to that version of Gradle. It also validates that
such version exists.
Note, you can also specify latest
, release-candidate
, nightly
, or release-nightly
, for example:
./gradlew wrapper --gradle-version latest
Moving between all
and bin
distributions
./gradlew wrapper --distribution-type bin
This will move you away from a giant zip to a large zip.
Replacing existing wrapper with one you trust
As noted in my post on Gradle security considerations you should generally replace the wrapper of any external project you clone as it might have some nasty surprises. Wrapper task can help you do that using Gradle installation you already trust.
rm -fr gradle/wrapper/ gradlew*
path/to/trusted/gradlew wrapper --gradle-version latest
That is all!