The Gradle wrapper is some files(bash/bat/jar/properties) created by the “gradle wrapper” command with which a user can run the scripts(bash/bat) to perform all the Gradle command operations without installing Gradle in the environment. All the files are supposed to commit into VCS like Git. Using the Gradle wrapper has the following 2 benefits:
No need to install Gradle before building a Gradle project;
Make the building process use the exact Gradle version as the Gradle project author wanted.
To run the Gradle wrapper:
# For Unix like OS.
When you use the Gradle wrapper to perform Gradle operations, the script will download the specific version of Gradle package file first if it didn’t, install it to the “$USER_HOME/.gradle/wrapper/dists” directory, then execute the command.
To generate the Gradle wrapper for your Gradle project, you just need to run the following command under your Gradle project directory:
You can specify the Gradle version you want the Gradle wrapper use:
gradle wrapper --gradle-version 2.3
If no version is given like in the earlier case, by default the Gradle version in your environment is used.
There are also some properties in the “gradle-wrapper.properties” file you can updated, such as the “distributionUrl” property which is used for the Gradle wrapper script to download the Gradle package file. More information can be found in the offical document.