/commands/gradle/gradle-wrapper-upgrade
gradle wrapper --gradle-version: upgrade the Gradle wrapper
- tool
- Gradle
- versions
- Gradle 7.x, Gradle 8.x, Gradle 9.x
- os
- any
./gradlew wrapper --gradle-version 8.14.3 upgrades the project's Gradle wrapper: it writes the new version into gradle/wrapper/gradle-wrapper.properties. Run ./gradlew wrapper (or any task) a second time so the new Gradle version also regenerates gradlew, gradlew.bat and gradle-wrapper.jar with its own scripts, then commit all four files. Everybody who runs ./gradlew afterwards gets the new version.
Upgrade
./gradlew --version # current wrapper version
./gradlew wrapper --gradle-version 8.14.3 # pin a version
./gradlew wrapper --gradle-version latest # newest stable release
./gradlew wrapper # second run: new scripts and JAR
./gradlew --version # confirm
git add gradlew gradlew.bat gradle/wrapper/Pass the exact version you want. Optional flags add a checksum and choose the distribution type:
./gradlew wrapper --gradle-version 8.14.3 --distribution-type all
./gradlew wrapper --gradle-version 8.14.3 --gradle-distribution-sha256-sum SHA256The properties file
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
distributionSha256Sum=SHA256Editing distributionUrl by hand also changes the version, but running the wrapper task keeps the scripts and JAR in step and validates the arguments.
Options of the wrapper task
| Option | What it does |
|---|---|
| --gradle-version 8.14.3 | Gradle version to use; also latest, release-candidate, nightly, or 9 / 9.1 for the newest matching release |
| --distribution-type bin|all | bin (default) has only the runtime; all adds sources and docs for IDEs |
| --gradle-distribution-url URL | Download Gradle from a mirror or internal server |
| --gradle-distribution-sha256-sum SUM | Check the downloaded distribution against a checksum |
| --network-timeout MS | Download timeout in milliseconds |
| --no-validate-url | Skip checking that the distribution URL exists |
Pitfalls
- JDK compatibility. Every Gradle version supports a range of Java versions. Running a new JDK with an old Gradle fails with Unsupported class file major version; upgrading the wrapper is the usual fix. Check the compatibility matrix in the Gradle documentation before choosing a version.
- Deprecations become errors. Major upgrades remove APIs that the previous version only deprecated. Run
./gradlew build --warning-mode allon the old version first to see what will break. - Plugins. Old versions of the Android Gradle Plugin, Kotlin or Spring Boot plugins may not support the new Gradle. Upgrade them in the same change.
- Missing JAR. If
gradle-wrapper.jaris not committed (or is in.gitignore), CI fails with Could not find or load main class GradleWrapperMain.
How to confirm it worked
./gradlew --version prints the new Gradle version together with the JVM it runs on. git diff gradle/wrapper/gradle-wrapper.properties shows the new distributionUrl, and a clean ./gradlew build on CI confirms that the plugins work with it. See the Gradle wrapper for how the scripts find and download the distribution.
FAQ
Do I need Gradle installed to upgrade the wrapper?
No. Run the wrapper task through the existing wrapper: ./gradlew wrapper --gradle-version X. The old version runs the task and writes the new version into gradle-wrapper.properties.
Which files must be committed after the upgrade?
gradlew, gradlew.bat, gradle/wrapper/gradle-wrapper.jar and gradle/wrapper/gradle-wrapper.properties. Without the JAR, the wrapper fails with Could not find or load main class org.gradle.wrapper.GradleWrapperMain.
How do I find the latest Gradle version?
Use --gradle-version latest (or release-candidate, release-nightly, nightly) with the wrapper task, or check the Gradle releases page. Read the upgrade notes before jumping a major version.