Gradle Wrapper - pford68/gradle-examples GitHub Wiki

It is the preferred way to build with Gradle, allowing users to build with Gradle without having it installed on their systems. The Gradle Wrapper files are designed to be committed to source control so that anyone can build the project without having to first install and configure a specific version of Gradle. The Gradle Wrapper consists of a batch script for Windows and a shell script for OS X and Linux. These scripts perform the magic that allows you to run a Gradle build without requiring that Gradle be installed on your system.

To use Gradle Wrapper:

  1. Add the following block to the bottom of your build.gradle.
task wrapper(type: Wrapper) {
    gradleVersion = '2.3'
}
  1. Run gradle wrapper.
    • After this task completes, you will notice a few new files.
    • The two scripts are in the root of the folder, while the wrapper jar and properties files have been added to a new gradle/wrapper folder.

The Gradle Wrapper is now available for building your project. Add it to your version control system, and everyone that clones your project can build it just the same. It can be used in the exact same way as an installed version of Gradle. Run the wrapper script to perform the build task, for example:

./gradlew build

The first time you run the wrapper for a specified version of Gradle, it downloads and caches the Gradle binaries for that version. Again, the Gradle Wrapper files are designed to be committed to source control so that anyone can build the project without having to first install and configure a specific version of Gradle.

References