How to use Gradle Wrapper

In this tutorial, we will show you how to create Gradle wrapper for your project and how to use it.

What is Gradle wrapper?
The Gradle wrapper allows you to run a Gradle task without requiring that Gradle is installed on your system.

1. Create a Gradle Wrapper

1.1 Declares a wrapper task.


task wrapper(type: Wrapper) {
    gradleVersion = '2.10' //we want gradle 2.10 to run this project

1.2 Run the wrapper task with gradle wrapper

$ gradle wrapper



1.3 The following files will be created, remember to add these files and folders to your version control system (e.g GitHub or Bitbucket).

  |--- wrapper
      |--- gradle-wrapper.jar

Review the gradlew file, a unix shell script to run the Gradle task.

2. How to use Gradle Wrapper?

2.1 Assume your Gradle project along with the Gradle wrapper files are added to GitHub, and someone wants to clone your project and try to run it without installing Gradle on their system.

2.2 They can download the project and run it with gradlew, read comments for self-explanatory :

$ git clone
$ cd spring4-mvc-gradle-annotation-hello-world

# wait, build? we don't have Gradle install yet? No problem, gradlew will handle it.
$ ./gradlew build  

# first time, download the gradle 2.10..
# download project dependencies
# run the gradle build task
#, we run a Gradle task without installing Gradle!

# try run jettyRun task
$ ./gradlew jettyRun
16:16:21 INFO  Jetty 9.2.10.v20150310 started and listening on port 8080
16:16:21 INFO  spring4 runs at:
16:16:21 INFO    http://localhost:8080/spring4
Press any key to stop the server.

$ ./gradlew task



  1. The Gradle Wrapper
  2. Building Java Projects with Gradle

About the Author

author image
Founder of, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.


5 Comment threads
0 Thread replies
Most reacted comment
Hottest comment thread
4 Comment authors
Mark HimsleyCarolkuanlinaffz trash Recent comment authors
newest oldest most voted

Thanks, very clear to get the concept.

Jenkins – Could not find GradleWrapperMain

[…] To fix it, create a Gradle wrapper again, and make sure the following files and folders are added to your version control system like […]


Why I always get this error after execute ./gradlew build
Exception in thread “main” error in opening zip file

Mark Himsley
Mark Himsley

Out of date – deprecated in Gradle 5

affz trash
affz trash

trash tutorial. big trash. blur