This action will protect project developers before using different Gradle version on each development machine and make development environment setup easier for the new contributors.
As a final effect you should get these files:
gradlew - Unix script version gradlew.bat - Windows script version gradle/wrapper/ gradle-wrapper.jar - jar with Gradle distribution used by wrapper script gradle-wrapper.properties - self expained
To generate these files, in console go to the project directory and execute:
As you remember from Setup Java project with Gradle wrapper task is one of the default Gradle tasks, so you got this feature for free.
Build Setup tasks ----------------- init - Initializes a new Gradle build. [incubating] wrapper - Generates Gradle wrapper files. [incubating]
If your project should includes different Gradle version than currently installed on your machine then use additional argument:
gradle wrapper --gradle-version 2.4
Now you can use generated scripts to execute tasks, e.g.
To have full Java/Gradle wrapper project initialisation you should activate Gradle plugin in the IDE (IntelliJ IDEA) by defining:
Gradle pluging window should be available with similar content:
All the genearted Gradle Wrapper files should be commited to the repository.
Remember to exclude gradle-wrapper.jar file, because usually .jar files by default are ignored in .gitignore file. You should add extra line:
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) !gradle-wrapper.jar