Gangmax Blog

The Gradle Wrapper

From here and here.

The recommended way to execute any Gradle build is with the help of the Gradle Wrapper (in short just “Wrapper”, i.e. the “gradelw” script). The Wrapper is a script that invokes a declared version of Gradle, downloading it beforehand if necessary. As a result, developers can get up and running with a Gradle project quickly without having to follow manual installation processes.

How do I add the Gradle wrapper to a new project?

Make sure you have Gradle installed, in an empty directory run “gradle init” to start the Gradle project setup wizard.

1
2
3
4
5
6
7
8
> gradle init
Starting a Gradle Daemon (subsequent builds will be faster)
Select type of project to generate:
1: basic
2: application
3: library
4: Gradle plugin
Enter selection (default: basic) [1..4]

How do I add the Gradle wrapper to an existing project?

This is useful if you have a project which doesn’t have a wrapper. Navigate to the project directory and run gradle wrapper.

1
2
3
4
5
6
7
> gradle wrapper
Starting a Gradle Daemon (subsequent builds will be faster)
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 9s
1 actionable task: 1 executed

How do I execute a Gradle build using the wrapper?

1
> ./gradlew tasks

How do I execute a Gradle build using the wrapper?

1
> ./gradlew wrapper --gradle-version <version-number>

How do I execute a Gradle build using the wrapper?

1
> ./gradlew wrapper --gradle-version <version-number>

Where does the Gradle wrapper store Gradle?

1
> ls -l ~/.gradle/wrapper/dists/

Comments