Jump to ratings and reviews
Rate this book

Building and Testing with Gradle: Understanding Next-Generation Builds

Rate this book

Build and test software written in Java and many other languages with Gradle, the open source project automation tool that’s getting a lot of attention. This concise introduction provides numerous code examples to help you explore Gradle, both as a build tool and as a complete solution for automating the compilation, test, and release process of simple and enterprise-level applications.

Discover how Gradle improves on the best ideas of Ant, Maven, and other build tools, with standards for developers who want them and lots of flexibility for those who prefer less structure.

Use Gradle with Groovy, Clojure, Scala, and languages beyond the JVM, such as Flex and C Get started building a simple Java program using Gradle's command line tooling and a small build script Learn how to configure and construct tasks, Gradle's fundamental unit of build activity Take advantage of Gradle's integration with Ant Use Gradle to integrate with or transition from Maven, and to build software more cleanly Perform application unit and integration tests using JUnit, TestNG, Spock, and Geb

110 pages, Paperback

First published May 6, 2011

16 people are currently reading
45 people want to read

About the author

Tim Berglund

4 books

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
7 (6%)
4 stars
31 (27%)
3 stars
56 (50%)
2 stars
16 (14%)
1 star
2 (1%)
Displaying 1 - 23 of 23 reviews
8 reviews
October 26, 2013
While it's a lot better than the official documentation, it still is a fairly sparse reference. It has many solid examples, but doesn't spend enough time exploring non-standard use cases (with the exception of the section on tasks, which is very good).

If you're working on migrating from a legacy build system to gradle, this is probably a helpful book; however, if you're writing everything from scratch and want to start with modern best practices, I'd look elsewhere.

I was most disappointed with the section on testing, which seems incomplete. It spends only a couple pages describing JUnit and TestNG, but devotes even less space to more expressive frameworks like Spock.
Profile Image for Jeanne Boyarsky.
Author 28 books76 followers
September 8, 2018
I saw “Building and Testing with Gradle” at the public library. The book is from 2011 so I knew it wouldn't cover the latest. It's just under 90 pages. I never formally learned gradle; just started using the pieces I needed. So a short intro book was perfect.

The book starts out by teaching the building blocks. I really like how they showed the same example with different syntax so you could learn what was equivalent. I also liked the emphasis on the init/config/execute phases; something I didn't understand as well as I should of.

There were chapters on integrating with Ant and Maven along with multi-module projects.

I learned a lot and not obsolete!
Profile Image for Rod Hilton.
152 reviews3,116 followers
August 5, 2011
Building and Testing with Gradle is the first Gradle book on the market. It's really no surprise, then, that the book is incredibly short, a mere 90 pages including generous helpings of long code samples. This may seem like a complaint, but it's quite the opposite: Building and Testing with Gradle is incredibly short and very much to the point. It is intended as an introduction to Gradle, and it accomplishes that goal very well.

Within the next few months there will surely be another Gradle book, maybe a "Definitive Guide" or something similarly named. That book will contain every little detail of the Gradle build system, and it will probably be good for someone who really wants to understand the internals of Gradle. But Building and Testing with Gradle has the goal of getting the reader introduced to Gradle and using it in projects right away, so it doesn't muddy the informational waters by including anything other than the necessities of what someone needs to be productive.

The book can easily be read in a single sitting, and due to its organization it would work well as a handy cookbook-esque reference after the fact.

Gradle is in an interesting predicament: the 'build system' war was settled a while ago. People who want good dependency management and standardized builds use Maven. People who want flexibility and control use Ant (and usually with Ivy to add dependency management). Sometimes people who hear about Gradle respond with a "who cares?" The authors are well aware of this situation, and so they very quickly try to sell the reader on Gradle. Chapter 1 deals with how to set it up, and Chapter 2 deals with why you'd want to use it. Chapter 2 reads almost like a marketing slideshow, sort of presenting a random sampling of powerful Gradle features, but they are tied in well with the narrative of the chapter, which is explaining the underlying object model Gradle uses for tasks. By the end of Chapter 2, the authors hope your attitude is "okay, I like Gradle, and I want to start using it."

Chapter 3 immediately starts answering that question, focusing on Gradle's integration with Ant. Chapter 4 follows suit, doing the exact same thing but for Maven. After two short chapters on Testing and Hierarchical Builds, the book is over.

One of my biggest complaints about Gradle is that, because it enables writing code inside of a build (something that Maven makes damn-near impossible), I have to start worrying about testing my build code. Gradle doesn't have any kind of facility for unit-testing build scripts, and it doesn't supply any kind of file system mocking or anything like that, which leaves me somewhat concerned. Tim and Matt address this directly, saying that Gradle uses Groovy to parse the Gradle DSL, but it should not be used to write a great deal of code. Code belongs in separate Java or Groovy classes, which can be unit tested. I was very happy to see this, because I feel like Building and Testing with Gradle will be a lot of people's first Gradle book, so this advice starts the community out on the right foot.

I found the chapter on Multiproject Builds the most interesting (particularly because I have a multiproject system at work and would like to start using some of the methodologies discussed) but I'd have liked to see a bit more coverage of how well it plays with other build systems. The bulk of the book was devoted to discussing how Gradle plays with Ant and Maven, but I was left wondering if the only way to enable Multiproject Builds was to use Gradle in all subprojects. I have no concept of how it would handle a Grails project, either (though the book did give me enough of an understanding of Gradle that I'd know what to look for).

If you're curious about Gradle or eager to start using it within an already-existing project, Building and Testing with Gradle is the perfect book. It gives enough of the basics to get you comfortable with the system, and covers a lot of ground in terms of working Gradle into existing Ant or Maven builds, including a bit of discussion about migration strategy. It's the perfect length to pick up and get started right away, and it leaves out a lot of the nuts and bolts to avoid confusing the reader early-on. I know that Tim and Matt are writing followup volumes with more detailed looks at some aspects of Gradle, and I'm very excited to read those as well. I highly recommend this book for people looking to spice up their builds with Gradle.
Profile Image for Aykut.
9 reviews1 follower
January 2, 2012
The other day, i was reading an article on Gradle. After reading it, I thought I should give it a try.
So I found this book.

Somewhere in this book, it says :
Gradle offers the flexibility of Ant, which many teams still cherish, but with the dependency management style of Ivy, the intelligent defaults of Maven, the speed and hashing of Git, and the meta-programming power of Groovy.


It's obviously attractive.
I had a very little usage of Ant, a few years ago. I use Maven intensively. I never used Ivy.
In fact, my real interest here was to know if I could (and should) replace Maven by Gradle in my projects.
So, to effectively replace Maven, i need Gradle to be able to generate projects (maven archetypes), eclisify my projects, support multi projects, and being, of course, more flexible than Maven.

I didn't see actually something about initializing a project in this book. Maybe i missed it. I must say that i've read the book late in the night ;)
But very easily, i created a task which creates all the source structure i want, in a few lines.
Of course, it's not yet exactly a maven archetype like. There is actually a JIRA ticket about that (http://issues.gradle.org/browse/GRADL...).
I can create a complex structure very easily.
Gradle can also eclipsify your project very easily. You just have to apply the eclipse plugin, and type gradle eclipse in your favorite terminal.
Gradle obviously supports multi projects, and it's very flexible. I love the way you can put all your build configuration in one top build.gradle, or separate your build in several build.gradle, for each subproject.
You can also go in a hybrid way, using both methods.

So, i can say that Gradle do what i do with Maven in every day use. But is there a real interest for me to use it?
I would say yes. I feel to have a real power in my hands, with Gradle tasks.
After a glance to the documentation, the list of available plugins and examples, it seems that i'll really enjoy using Gradle.

I tried to transform an old school project, which doesn't use Ant or Maven, into a Gradle project.
I also tried to transform a Maven project, into a Gradle project.
It was a success both times. And I am amazed how fast it went.

If you look at Gradle's Jira, you'll see there is 630 majors issues, 31 critical and 7 blocker.
630 major is huge, but calm down. A lot of them are wishes, improvements or new features.
There is in fact today 268 bugs.

Conclusion : I really have a good feeling about Gradle. This book is a nice introduction to Gradle, but i suggest to have a look at the online documentation, where you can find useful snippets and examples. Now i'll have to convince my colleagues ;-)
Profile Image for Martin Chalupa.
224 reviews5 followers
September 6, 2017
This book covers very basic overview about Gradle. I would recommend it for someone who only know that Gradle exists and it a build tool. It goes over basic ideas of Gradle and how to use it's building block - task. I haven't check how the book is up to date with the latest version of Gradle. It was written just for 1.0 version and I time when I went through the book the latest version was 4.1. I recommend to approach all information in the book with caution. They might not be valid anymore.
11 reviews
April 14, 2018
Good entry point on Gradle, but not really practical for Java as it doesn't contain much on the Java plugin.
Author 3 books6 followers
March 25, 2018
Not sure you need a book for this if you already know maven but there are some issues. Helps to know groovy also.
Profile Image for Chris Wood.
42 reviews4 followers
May 6, 2013
I thought that the authors did a good job describing the merits of gradle over maven and ant but did not go much further. One is left with a distinct impression of the contours of the gradle dsl to get started. The advantage of this approach is its overall brevity. The disadvantage is its lack of concrete (or theoretical) depth. I suspect the authors made that decision because gradle is an internal dal to the groovy language and includes full support of maven and ant. The "full treatment" would quickly involve a catalogue of groovy language features and ant / maven techniques, all of which are covered elsewhere in greater detail. I would have enjoyed a sample, non-trivial example toward the end of the book.

Nevertheless, I thought this was a great narrative entry into gradle to be read alongside the gradle docs!
Profile Image for Denis.
8 reviews1 follower
Read
July 15, 2013
Gradle can act either as a superset of Ant with embedded support of Ivy or as a flexible variant of Maven. However it also provides you with all means that any next generation build tool should provide. Moreover, instead of using XML Gradle uses a very concise and easy to read domain-specific language based on Groovy. This combination of the DSL and a really rich object model allows to adapt Gradle to virtually any build process.
Profile Image for Ronald.
33 reviews2 followers
July 9, 2011
A short read but answers many of the questions a Gradle newbie would ask. Much of the material was already familiar to me but I had to invest weeks to gain that knowledge. If you are starting a Gradle project this book should be sitting next to you. One piece of advice, looking at the Gradle source will save you a bunch of time and give you new ideas on how to solve problems.
Profile Image for Stephen.
Author 7 books16 followers
September 17, 2013
A good guide into what gradle is and how it differs from ant and maven. I particularly liked that, while the book explains how gradle builds on experiences with ant and maven, it isn't necessarily "better" as there are some problems for which Maven works well.
Profile Image for Ahmad.
3 reviews
Read
November 30, 2015
very summarized to Gradle, like Hi, nice to meet you Gradle, but how I would get to know Gradle? needs more practical examples, another book of course. This should be enough if you don't have the time
Profile Image for Nick.
14 reviews
January 20, 2016
Didn't really contain any information that wasn't easily available on the web, and was much too short. If you're looking for a basic Gradle introduction you can do better than this book.
Profile Image for Joao Trindade.
66 reviews4 followers
February 20, 2014
Not great at explaining gradle's way of thinking.

The middle part seems more like a man page then an introductory books.

The start and end of the book are clearly the best parts.
Profile Image for Kirill.
78 reviews14 followers
February 23, 2015
"Building and testing with Gradle" and "Gradle beyond the basics" are two nice little books, terse and still up to date.
87 reviews5 followers
June 21, 2015
not so good, at least it is short
Displaying 1 - 23 of 23 reviews

Can't find what you're looking for?

Get help and learn more about the design.