Home > Articles > Web Development

  • Print
  • + Share This
Like this article? We recommend Using the Gradle Wrapper

Using the Gradle Wrapper

Gradle has had tremendous uptake in the Groovy community and, even investigation from some of the Android team for building the Android SDK, Gradle is a very young project. It's not reasonable to expect that everyone will have it installed. The Gradle wrapper provides a way to distribute projects built with Gradle to developers with scripts that proxy to a local Gradle install, if available, or download and install Gradle within the local project's directory, if needed.

To add the wrapper to our project, you need to add the following task to your build.gradle file:

task wrapper(type: Wrapper) {
  gradleVersion = '1.0-milestone-3'

where gradleVersion is the version you'd like the project to use. After adding this task, execute

gradle wrapper

to generate the wrapper files. After doing so, commit or zip the wrapper files to your favorite version control system or file system.



Gradle is a very powerful build tool that attempts to take the best features of Ant and Maven and make it more easy to use. In this article, we learned how to create a build file, add and use dependencies and repositories, and how to let other developers use Gradle even if they have it installed. We've learned a lot but only barely scratched the surface. Fortunately, Gradle has an extensive user guide on its website. You can learn more about Gradle at http://gradle.org.

The sample code used in this project is available at https://github.com/jwill/informit-articles/tree/master/GradleBuildSystem.

  • + Share This
  • 🔖 Save To Your Account