Skip to content

/glossary/gradle/gradle-wrapper

What is the Gradle Wrapper (gradlew)?

The commands on this page have not been executed by our verification runner yet.updated
tool
Gradle
versions
Gradle 7.x – 9.x
os
linux, macos, windows

The Gradle Wrapper is a small set of files committed with a project (gradlew, gradlew.bat and gradle/wrapper/) that runs the build with a specific Gradle version. The first time you run ./gradlew build, it downloads that version into ~/.gradle/wrapper/dists/ and then uses it; later runs reuse the download. Nobody needs Gradle installed, and every developer and CI job builds with the same version.

The files

FilePurpose
gradlewShell script for Linux and macOS
gradlew.batBatch script for Windows
gradle/wrapper/gradle-wrapper.jarSmall program that downloads and starts the right Gradle distribution
gradle/wrapper/gradle-wrapper.propertiesWhich Gradle version to use (distributionUrl) and where to store it

Commit all four. The version lives in distributionUrl:

gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-X.Y-bin.zip

(X.Y stands for the Gradle version of the project.)

Use it

bash
./gradlew build          # Linux, macOS (Git Bash too)
gradlew.bat build        # Windows cmd / PowerShell: .\gradlew.bat build
./gradlew --version      # Gradle version the wrapper uses

If ./gradlew fails with Permission denied on Linux or macOS, the execute bit was lost (common after a checkout from Windows): run chmod +x gradlew and commit it with git update-index --chmod=+x gradlew.

Upgrade the Gradle version

bash
./gradlew wrapper --gradle-version X.Y    # rewrites the properties file and scripts
./gradlew wrapper                         # run again so the new version updates the wrapper JAR too

Run it twice as shown: the first run uses the old Gradle to write the new version; the second runs with the new version and refreshes the wrapper files themselves. Commit the changed files.

Sources