Skip to content

Adding Gradle Wrapper to an existing project

This quick tutorial will show the few steps for adding Gradle Wrapper to an existing project, in order to reduce the manual steps required to run it.

Gradle Wrapper

As developers, we tend to work on multiple projects at the same time, especially when developing on top of a microservice architecture. The manual setup of the tools and their required versions to run these projects can easily become a pain, and that’s no different with Gradle.

Fortunately, we can add Gradle Wrapper to an existing project so we can ship the runnable of Gradle as part of the source code.


It’s as simple as running the wrapper task on the root folder of your project. The following will generate the wrapper of the currently installed version:

gradle wrapper

This will generate the files gradlew and gradlew.bat, and a gradle directory. Now you can simply invoke the Gradle wrapper by running:

./gradlew build

How to specify the Gradle version?

To generate the wrapper of Gradle version 6.0 for example:

gradle wrapper --gradle-version 6.0

Go the Gradle releases page to check what versions are available.

What about old Gradle versions such as 2.3 and older?

First of all, I’d recommend updating to a more up-to-date version unless you have a very good reason to keep it that old. If you have that good reason however, add the following to your build.gradle file:

task wrapper(type: Wrapper) {
   gradleVersion = '2.3'

And now you can run:

gradle wrapper

Hope it helps! Cya =]


Leave a Reply

Your email address will not be published. Required fields are marked *