Use the Gradle Wrapper and Stop Wasting Valuable Time

DZone 's Guide to

Use the Gradle Wrapper and Stop Wasting Valuable Time

When you use the Gradle Wrapper, you embed some intelligence into your project.

· Java Zone ·
Free Resource

If you’ve ever migrated a team from one build tool to another, you’ll understand that this process is full of peril.  Changing build tools, or for that matter, anything involved in the development process usually means that you have to change people’s habits.  Developers used to Ant or Maven now have to learn Gradle.  Some on your team may be excited to learn a new tool, others might be skeptical of the change, and some people on your team may not want to see any change at all.

Good developers have strong opinions about the tools they use, and, very often, changing build tools provokes heated arguments.  I’ve been there.  When you are responsible for managing and migrating a build, you have to introduce, train, support, and defend technology choices to a whole spectrum of users.  It’s a tough job, and I’ve learned the hard way that whoever is responsible for builds is also something of a “lightning rod” for the entire department. 

Installing a New Build Tool (times one thousand)

One of the challenges I’ve had to face at large organizations is tool distribution - how do you distribute a new tool to multiple developers?  Imagine you have thousands of developers who need to move to a new build tool.  Years ago with a tool like Ant, the process went something list this: 

  1. Write a simple set of instructions for installing Apache Ant.
  2. Tell developers to download the software, unzip an archive, set a few environment variables, and then verify the installation.

Simple, right?  Not so fast, you need explicit instructions for each operating system.  Maybe there is a wide variety of audiences: from operations to development to QA.  After you write three separate documents (one for each platform, at least), you’ll have to send it to the entire department:

“Attention all developers you will need to upgrade to the new version of Ant.  All of you need to go to ant.apache.org, download the archive, …...,” and so and so forth.

Fact: No One Reads these Emails

What usually happens at this point is that developers, busier than ever, have a habit of ignoring emails like this.  They have requirements to complete, issues to fix, angry bosses to cater to....  After a few weeks of silence from the developers and broken builds, a build migration now requires you to remind developers in person that they need to upgrade to a new version of a build tool.  

You become both the Ambassador of the New Build Tool and the person that has to stand over everyone’s shoulders and remind them to upgrade.

“Oh, that build guy is back to pester us about this upgrade.  We don’t have time for this.  We have software to write and who cares if we don't upgrade to the new build tool...”

There’s has to be a better way... and there is: the Gradle Wrapper

Forget writing instructions for installing yet another tool.  When you use the Gradle Wrapper, you embed some intelligence into your project.  When some one runs the build for the first time, they run “gradlew” which is an automatically generated shell script (or Batch script on Windows) designed to download Gradle.   As the build manager, you generate this file from your Gradle build so that you don't have to write instructions for installing Gradle.

The Gradle Wrapper takes build automation to another level - Gradle can, effectively, install itself.  First time users of the build don’t have to stop and read some distracting set of instructions.  They don’t have to fumble around with downloads or the Windows control panel to set environment variables.

The only instructions you’ll have to write are:

“We’ve upgraded our builds to  Gradle    Just grab the code and run gradlew.  Everything is automated, even the Gradle download.   If you have questions, see me, but you won't because everything just works.  Have a nice day.”

If you use the Gradle Wrapper, you’ll never have to write instructions again.  You’ll never have to wonder if your developers are all using the same version of a build tool.  If Gradle ever needs to be upgraded, all you need to do is change the version used in the Gradle Wrapper and commit this code to your SCM.

It’s all about Saving Time

So, think back to that organization with a thousand developers.  If installing a new build tool takes just 15 minutes plus 20 minutes of email distraction, a simple update to a new tool costs an organization with 1000 developers a minimum of 583 hours (or 14.6 person weeks).  That’s 14.6 weeks of lost productivity just to move to a new build tool not counting the support time it costs you to make sure everyone has complied with upgrade instructions.

With the Gradle wrapper  there’s no email to read, there’s no issue with developers ignoring instructions, and, for a build engineer, you’ve reduced your support time to zero.  It may take 1.2 minutes for the Gradle Wrapper to download Gradle (assuming a 6 MBps connection and a 47.5 MB Gradle download).  Over the entire organization of 1000 developers this works out to about 20 hours (or a half a person week).  

Which would you prefer?  14.6 weeks of developers lost productivity from fumbling around with tool installation or a 0.5 weeks of lost productivity from a 1.2 minute download.  

In Summary: Use the Gradle Wrapper

When you use the Gradle Wrapper:

  • You enforce build standards automatically
  • You don’t have to worry about developers voluntarily complying with a set of complicated instructions.
  • You’ll save time across the entire organization
  • You won’t be wasting time installing build tools for developers
  • But, more importantly, your developers will be up and running with Gradle immediately

To learn more about Gradle and the Gradle Wrapper, go to http://www.gradle.org or watch this webinar about the Gradle Wrapper: http://www.gradleware.com/registered/screencasts/the-gradle-wrapper/


apache ant ,build tools ,gradle ,java

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}