Tuesday, April 30, 2013

Book Review: Gradle Effective Implementation Guide

The choice of build tools in the Java space has basically been Ant or Maven since the early days of Java.   Ant was the first tool to arrive and then Maven was created to help provide standardization, assuming you drank the Maven Kool-Aid, meaning that you could live with the standards set out by Maven.

Now a new build tool has arrived, Gradle.  Gradle adoption started slowly at first, but has definitely been picking up momentum as more and more projects migrate from either Ant or Maven over to Gradle. Gradle can't be ignored!

Gradle is built on top of the Groovy.  The tool provides a rich Domain Specific Language (DSL) based on Groovy. The DSL is the key component of Gradle.

  • Starting with Gradle, creating and working with build scripts 
  • Gradle for Java projects
  • Dependency management
  • Testing building and publishing artifacts
  • Multi-project builds
  • Gradle with Groovy and Scala
  • Maintaining code quality with tools like Checkstyle, PMD, FindBugs, JDepend, CodeNarc and the Sonar plugin - one of my favorite chapters since I recommend using code static analysis tools for improving code quality
  • Using Gradle with Continuous Integration - covers Jenkins, TeamCity and Bamboo
  • IDE support - provides excellent coverage of Eclipse and IntelliJ IDEA support
  • Very good reference guide
  • Sample source filled with a lot of complete examples
  • It's by Mr. Haki, creator of Groovy Goodness, Grails Goodness and of course, Gradle Goodness blog postings!
  • I started out running and verifying every example, but after submitting 6-7 errata for just the first chapter, I stopped running all of the examples and dropped back to just executing examples that peaked my interest.
  • The book contains only a single reference to Ant and no discussion on Gradle's integration with Ant.  In all fairness, Ant integration is not listed in the bullet points on the back of the book that shows "What you will learn", but I think that is a mistake.  Readers are going to be coming from either Ant or Maven and will be looking for help in migrating to Gradle or for help on how to do things in Gradle that they are already doing in Ant or Maven.
  • The book is 356 pages but a lot of pages are 'eaten up' by showing the output of all the example build scripts,  and screen shots from Chapter 11, Using Gradle with Continuous Integration and Chapter 12 IDE support.
The book is a very good reference for using Gradle and I would definitely recommend it for anyone interested in learning more about Gradle.

Gradle thoughts (not specific to the book)
This the second book I have read on Gradle.  I have read the User's Guide a couple times over the last two years in an attempt to get a firm grip on Gradle.  One of my challenges is that I don't get to use Gradle in my day job, just at night and on weekends.   This limited use seems to extend the learning curve, which I think for Gradle is larger/longer than other tools.

"Convention over configuration" is great for reducing the amount of code in projects, BUT somewhere the user needs to know where the conventions are defined.   I think one of the keys to learning Gradle is to get a firm grasp on the Gradle DSL.  Without a grasp on the DSL,  a new Gradle user just keeps wondering "Where are these properties/methods coming from?"


  1. Hello Mike,

    thanks for the review. I totally agree with you. The learning curve is steep especially if you try to understand where all the magic comes from. Learning how to read the DSL-Reference is the first big obstacle. To understand how groovy closures and the meta object protocol works helps a lot.

    How is the plugin topic covered in the book? Could you say something to that topic?


    1. Chapter 10 is titled 'Writing Custom Tasks and Plugins'. The chapter seems to be about an even split between custom tasks and plugins. It talks about the different options for placement of the code, like in the build file or in the project source directory. The same goes for plugins, so as a result, there are about 10 pages that cover creating plugins, in various places and some coverage on testing plugins.

      This is an area that I would have liked to seen more coverage, but honestly I haven't been looking around either to know what else is out there. If I can find the spare time, this is one area that I want/need to spend some time getting acquainted with.