gradle Gradle Wrapper Gradle Wrapper introduction

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

Gradle has the ability to add a wrapper to projects. This wrapper alleviates the need for all users or continuous integration systems to have Gradle installed. It also prevents version issues where there is some incompatibility between the version the project uses and that which users have installed. It does this by installing a version of gradle locally in the project.

Users of the project simply run:

> ./gradlew <task> # on *Nix or MacOSX
> gradlew <task>   # on Windows

To setup a project to use a wrapper, developers:

  1. Execute:
gradle wrapper [--gradle-version 2.0]

Where --gradle-version X is optional and if not provided (or the wrapper task isn't included, as shown below), the version used is the version of gradle being used.

  1. To force the project to use a specific version, add the following to the build.gradle:
task wrapper(type: Wrapper) {
    gradleVersion = '2.0'
}

When the gradle wrapper command is run it creates the files:

the_project/
  gradlew
  gradlew.bat
  gradle/wrapper/
    gradle-wrapper.jar
    gradle-wrapper.properties

The official documentation on this feature is at https://docs.gradle.org/current/userguide/gradle_wrapper.html.



Got any gradle Question?