Source code for the Manning book "Gradle in Action"
Java CSS JavaScript Groovy XSLT Puppet Other
Switch branches/tags
Nothing to show
Failed to load latest commit information.
appendixB Fixed some empty listings and cleaned up formatting Nov 28, 2013
buildSrc/src/main Test JsHint task. Sep 5, 2015
chapter01 Fixed formatting Nov 29, 2013
chapter02 updated to match Listing 2.1 Jun 9, 2014
chapter03 Declare task dependency on classes task Aug 9, 2016
chapter04 Add example using buildSrc directory Aug 9, 2016
chapter05 Regenerated WAR file with Java 6 source and target compatibility. Sep 5, 2015
chapter06 Fixed name of subproject Jul 24, 2014
chapter07 Carry through report separation from previous code example. Oct 10, 2015
chapter08 Simplified some of the plugin code. Nov 30, 2013
chapter09 Change prop name to avoid conflict with Project.getBuildDir() Jan 29, 2015
chapter10 Align with IdeaLanguageLevel in book Jan 15, 2016
chapter11 Adapt to new NPM node modules path Feb 20, 2016
chapter12 Removed optional project declaration. Nov 30, 2013
chapter13 Fixed formatting Nov 29, 2013
chapter14 Simplified some of the plugin code. Nov 30, 2013
chapter15 No need to put this configuration code into task. Nov 29, 2013
gradle/wrapper Upgraded Wrapper to 1.7 Aug 18, 2013
.gitignore Ignore Vagrant directory Jul 11, 2013
.travis.yml Not needed May 9, 2017
LICENSE.txt Added MIT license Nov 15, 2015 Clearly indicate compatible Gradle version Aug 27, 2017
build.gradle Upgraded Wrapper to 1.7 Aug 18, 2013
gradlew Initial version - first 7 chapters May 19, 2013
gradlew.bat Initial version - first 7 chapters May 19, 2013

Source code for "Gradle in Action" Build Status

Book cover

Building the code

All source code used in the book is based on Gradle 1.7. Please use the checked-in Wrapper to execute the samples. Please be aware that a later version of Gradle might not be compatible with the source code.

The source code is organized into individual chapters. Chapter 1 contains Ant and Maven build scripts. Please refer to the build tool's online manual for instructions to install the runtime and execute the build script. You can find more information here:

Starting with chapter 2, all source code can be run using the Gradle Wrapper which means no runtime will have to be installed. For example to run the "Hello World" build script from chapter 2 open a shell/command prompt and navigate to the directory. You can execute the build script by referencing the Gradle Wrapper command line script and providing the task you would like to run.


> cd gradle-in-action-source/chapter02/helloworld-task-doLast
> ../../gradlew.bat helloWorld


$ cd gradle-in-action-source/chapter02/helloworld-task-doLast 
$ ../../gradlew helloWorld

Putting it all together

Gradle in Action demonstrates how to implement build logic needed for various stages of a Continuous Delivery pipeline. While the book discusses specific functionality step by step, you might want to see it all put together. You can find the sample To Do application extended by typical project automation functionality (like testing strategies, publishing and deployment logic etc.) in a dedicated repository.

Going further

The book discusses how to integrate third-party functionality by writing custom tasks or plugins. Some of the examples have been developed further and are available as full-fledged binary plugins ready to be used in your own projects.

Unfortunately, I could not cover all topics readers were interested in. Here's a list of example projects that should get you started:

Continuous Integration

Most of the source code listings are automatically executed with the help of the Gradle tooling API. Whenever there's a change to the code, a corresponding job is triggered. Each build works through a list of predefined tasks for each chapter and verifies the expected outcome.