Scrivio Interview library
ConceptFoundations7 min read · updated 12 November 2026

What is the Gradle wrapper, why should every project use it, and how do you upgrade Gradle safely?

The Gradle wrapper is a pair of small scripts, gradlew and gradlew.bat, plus gradle/wrapper/gradle-wrapper.jar and gradle-wrapper.properties, committed to the repository. When we run ./gradlew, it downloads the exact Gradle version named in the properties file, if it is not already cached, and runs the build with it, so every developer and CI agent uses the same version. We upgrade by running ./gradlew wrapper --gradle-version with the new version, after clearing deprecation warnings and checking plugin compatibility, set distributionSha256Sum to verify the download, and validate the wrapper jar in CI.

Why this question is asked

Builds that depend on whatever Gradle happens to be installed are a common source of works on my machine problems: a developer on one version, CI on another, and a build that behaves differently on each. The wrapper solves that with almost no effort, and it also makes upgrading Gradle an ordinary, reviewable change. Interviewers ask this junior question because it is the foundation of reproducible Gradle builds, and the follow-up about upgrading shows whether we have done it safely. In this answer, we will look at what the wrapper consists of, how it runs a build, why every project should use it, how to upgrade, and how to protect it from tampering.

1What the Wrapper Consists Of

The wrapper is four files that live in the project and are committed to version control.

Text
my-service/
gradlew # shell script for Linux and macOS
gradlew.bat # the same for Windows
gradle/wrapper/gradle-wrapper.jar # small launcher that downloads and starts Gradle
gradle/wrapper/gradle-wrapper.properties # which Gradle version to use
# gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip
distributionSha256Sum=<sha-256 of that zip, from gradle.org>
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

Notice that the Gradle version is just part of the distributionUrl. The version shown here is an example; use the current one for your build. The -bin distribution contains Gradle itself, while -all also includes sources and documentation, which only helps IDEs show Gradle's source code for Groovy scripts.

2How ./gradlew Runs a Build

When we type ./gradlew build, the script starts a small Java program from gradle-wrapper.jar. That program reads the properties file, checks whether the requested distribution is already unpacked in the Gradle user home, by default ~/.gradle/wrapper/dists, and if not, downloads it, verifies the checksum if one is set, and unpacks it. Then it starts that Gradle version with our arguments.

Step throughWhat happens on ./gradlew build
Developergradlew scriptGradle user homeservices.gradle.org
./gradlew build
is gradle-9.2.0 unpacked?
no
download gradle-9.2.0-bin.zip
check distributionSha256Sum
unpack into wrapper/dists
start Gradle 9.2.0 with the build

7 messages in order. Play them, or step through them one at a time.

Later runs find the unpacked version and skip the download.

So the only thing a machine needs is a Java runtime to start the wrapper. The first run on a new machine downloads Gradle once, about 130 megabytes for recent versions, and every later run reuses it. Two projects on different Gradle versions simply have two distributions in the cache, and each runs its own.

3Why Every Project Should Use It

The first reason is consistency. The Gradle version is part of the build's behaviour: deprecations, defaults and plugin compatibility all change between versions. With the wrapper, every developer and every CI agent runs exactly the version committed in the repository, so a build that passes locally behaves the same in CI.

The second reason is that upgrades become ordinary changes. The version is in a committed file, so an upgrade is a pull request that CI tests, reviewers see, and git history records. If an upgrade causes trouble, reverting the commit reverts the Gradle version. The third reason is convenience: nobody has to install or manage Gradle, and old branches still build with the version they were written for. Teams should not even need a locally installed gradle command, except to create the wrapper in a brand new project.

4Upgrading Gradle Safely

An upgrade is a small change in files, but it is worth doing in a few careful steps.

YAML
# 1. On the current version, list everything that will break in the next major
./gradlew build --warning-mode all
# Deprecated Gradle features were used in this build, making it incompatible with Gradle 10.0.
# (followed by each deprecation and where it comes from)
# 2. Fix those, and check plugin versions against the new Gradle version
# (Spring Boot, Kotlin, Android and other plugins publish compatibility notes)
# 3. Update the wrapper, with the published checksum
./gradlew wrapper --gradle-version 9.2.0 --gradle-distribution-sha256-sum <sha-256 from gradle.org>
# 4. Run it a second time, so the new version regenerates the scripts and the jar
./gradlew wrapper --gradle-version 9.2.0
# 5. Build and test, then commit all the changed wrapper files
./gradlew build
git add gradlew gradlew.bat gradle/wrapper/

Notice step 1. Gradle prints deprecation warnings for features that will be removed in the next major version, and --warning-mode all shows each one with its source. Fixing them before upgrading turns the upgrade into a version bump. Plugins matter as much as our own scripts, because a plugin compiled against old APIs can fail on a new Gradle major, so we upgrade plugins to versions that support the target first.

Step 4 is easy to miss: the first wrapper task runs on the old version and only changes the properties file; running it again, now on the new version, updates the scripts and the jar to the new wrapper. Then we commit all four files, never only the properties file.

5Protecting the Wrapper

Two protections are worth having because the wrapper runs code on every developer's machine and every CI agent. The first is distributionSha256Sum in the properties file. With it, the wrapper verifies the downloaded Gradle zip against the checksum, which Gradle publishes for every release, and refuses to run a distribution that does not match.

The second protects the gradle-wrapper.jar itself, which is a binary file committed to the repository and easy to miss in a code review. A pull request that replaces it with a modified jar could run anything on CI. Gradle publishes checksums of every official wrapper jar, and the gradle/actions wrapper-validation action for GitHub Actions checks the jar in the repository against them. Recent versions of the setup-gradle action perform this validation as well; check your version. Other CI systems can do the same with a small script comparing the jar's checksum to the published list.

YAML
# .github/workflows/build.yml (excerpt)
- uses: actions/checkout@v4
- uses: gradle/actions/wrapper-validation@v4 # fails if gradle-wrapper.jar is not an official one
- uses: actions/setup-java@v4
with: { distribution: temurin, java-version: '25' }
- run: ./gradlew build

6Follow-up questions

Should gradle-wrapper.jar really be committed?

Yes. Without it, ./gradlew cannot start, and the point of the wrapper is that a fresh clone builds with no setup. It is small, and wrapper validation in CI covers the risk of a modified jar.

What Java version does the wrapper need?

Only a JVM that can run the requested Gradle version. Recent Gradle releases need a reasonably recent Java to run the daemon, for example Gradle 9 requires Java 17 or later, while the Java version used to compile and test our code is chosen separately with toolchains.

Can I skip major versions when upgrading?

It is possible, but going one major at a time is safer: each step's deprecation warnings tell us exactly what the next step will remove. Jumping two majors means some APIs disappear without our ever seeing their warnings on the version we are running.

7Conclusion

In this answer, we saw that the wrapper is the gradlew scripts, gradle-wrapper.jar and gradle-wrapper.properties, which download and run a pinned Gradle version so everyone builds with the same one. We upgrade by clearing deprecations shown by --warning-mode all, checking plugin compatibility, running ./gradlew wrapper --gradle-version twice and committing all the files, set distributionSha256Sum so downloads are verified, and validate the wrapper jar in CI to protect against a tampered jar.

What to say in the interviewAbout 90 seconds aloud

Open with

The wrapper is how a project pins its Gradle version. It is four committed files: the gradlew and gradlew.bat scripts, gradle-wrapper.jar, and gradle-wrapper.properties, which holds the distribution URL with the version.

Then, if they want more

When I run ./gradlew, the small launcher in the jar checks whether that version is already in the Gradle user home, downloads and unpacks it if not, and runs the build with it.

So every developer and every CI agent uses exactly the same Gradle, nobody needs to install it, old branches still build with their own version, and an upgrade is just a reviewed commit that can be reverted.

To upgrade safely, I first run the build on the current version with warning mode all, which lists every deprecated feature that the next major version will remove, and fix them. I also check that plugins like Spring Boot or Kotlin support the target version and upgrade them first.

Then I run ./gradlew wrapper with the new gradle-version and the published SHA-256, run it a second time so the scripts and jar are regenerated by the new version, build, test and commit all the wrapper files.

Two protections: distributionSha256Sum makes the wrapper verify the downloaded zip, and CI validates gradle-wrapper.jar against Gradle's published checksums, for example with the wrapper-validation action, so nobody can slip in a tampered jar.

About this answer

Last updated
12 November 2026
Versions it names
Java 17
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Gradle user manual
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "What is the Gradle wrapper, why should every project use it, and how do you upgrade...": https://scrivio-interview-library.netlify.app/java/gradle/3b94eeb9e1/