gradlew
is a wrapper- A wrapper is a script that invokes a declared version of
Gradle
, downloading it beforehand if necessary
When building projects on a cloud, use
./gradlew
overgradle
The former command executes an existing file while the later is a call to an executable that should have to been already installed and configured.
Adding the wrapper
- If you have a
Gradle
project that doesnβt already have a wrapper, you can add the wrapper - Every vanilla
Gradle
build comes with a built-in task calledΒwrapper
- Run
gradle wrapper
to generate the necessary wrapper files - Generated files,
gradle-wrapper.jar
- JAR file containing code for downloading theGradle
distributiongradle-wrapper.properties
- wrapper configgradlew
- a shell script to execute the build with the wrappergradlew.bat
- a windows batch script to execute the build with the wrapper
- The generated wrapper will reside within the
gradle
directory in the projectβs rootβββ a-subproject β βββ build.gradle.kts βββ settings.gradle.kts βββ gradle β βββ wrapper β βββ gradle-wrapper.jar β βββ gradle-wrapper.properties βββ gradlew βββ gradlew.bat
Wrapper definition
Found in gradle/wrapper/gradle-wrapper.properties
,
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
- Changing the
Gradle
version of a project is now a simple change in the wrapper definition. It can even be made by running./gradlew wrapper --gradle-version 8.3