Leanpub Header

Skip to main content

Gradle Goodness Notebook

Experience Gradle through code snippets

Learn more about Gradle features with code snippets and short articles. The articles and code will get you started quickly and will give more insight in Gradle.

Free With Membership

The author is letting you choose the price you pay for this book!

Pick Your Price...
PDF
EPUB
WEB
274
Pages
About

About

About the Book

In 2009 I started to write small blog posts about Gradle at Messages from mrhaki. The posts contained code samples of cool Gradle features I just didn't want to forget. The blog posts turned out to be a useful resource for people learning and using Groovy in their every day programming.

The Gradle Goodness Notebook contains the blog posts about Gradle previously mentioned on my blog. The posts have been edited slightly so they can be used for the book. The book gives a broad overview of all the great features we can find in the Gradle build tool.

Latest update on April 18, 2023 with the following blog posts:

  • Defining Plugin Versions Using Version Catalog
  • Grouping Version Catalog Dependencies Into Bundles
  • Set Test Framework Version Using Version Catalog With JVM Test Suite Plugin
  • Using Spock With JVM Test Suite Plugin
  • Add Extra Dependencies For Running Tests Using JVM Test Suite Plugin
  • Set Project Version In Version Catalog
  • Configure Test Task With JVM Test Suite
  • Publish Version Catalog For Sharing Between Projects

The book contains the following sections:

  • Configuration
  • Tasks
  • Command line
  • Java and Groovy
  • Managing Dependencies
  • Testing Support
  • IDE
  • Miscellaneous

Share this book

Price

Pick Your Price...

With Membership

Free!

$7.99

You pay

$7.99

Author earns

$6.39
$

All prices are in US $. You can pay in US $ or in your local currency when you check out.

EU customers: prices exclude VAT, which is added during checkout.

...Or Buy With Credits!

Number of credits (Minimum 0)

0
The author will earn $0.00 from your purchase!
You can get credits monthly with a Reader Membership

Author

About the Author

Hubert A. Klein Ikkink (mrhaki)

Hello. I am a passionate Groovy and Java developer based in Tilburg, The Netherlands. My goal is to write software, like Pixar makes movies, BMW makes cars, Bang & Olufsen makes audio and TV systems and Apple makes computers and devices: clean, elegant, user-centered and high quality.

Contents

Table of Contents

About Me

Introduction

  1. Gradle versions
  2. Code samples

Configuration

  1. Changing the Project Name
  2. Changing Name of Default Build File
  3. Display Gradle Information in the Build
  4. Setting Global Properties For All Gradle Builds
  5. Using Properties for Multiple Environments or Profiles
  6. Define System Properties in gradle.properties File
  7. Changing the Gradle User Home Directory
  8. Set Project Version In Version Catalog
  9. Different Ways to Set Project Properties
  10. Setting Plugin Version From Property In Plugins Section
  11. Using System Properties Lazily
  12. Using Environment Variables Lazily
  13. Shared Configuration With Conventions Plugin
  14. Custom Plugin Repositories With Plugins DSL
  15. Get Property Value With findProperty
  16. Lazy Project Property Evaluation
  17. Change Local Build Cache Directory
  18. Enable Build Cache For All Builds
  19. Using Objects for Version
  20. Build Script Using Java Syntax
  21. Check Operating System In Build Scripts
  22. Creation Rules For Rule Based Model Configuration Using Model DSL

Tasks

  1. Get User Input Values From Console
  2. Organizing Tasks Using The Task Container
  3. Group Similar Tasks
  4. Adding Tasks to a Predefined Group
  5. Getting Information About Buildscript Dependencies
  6. Create Properties File With WriteProperties Task
  7. Add Incremental Build Support to Tasks
  8. Add Incremental Build Support to Custom Tasks with Annotations
  9. Using Incremental Task Action
  10. Command Line Options For Custom Tasks
  11. Enable Task Based On Offline Command Line Argument
  12. Set Task Values with Project Convention
  13. Methods Generated For Setting Task Properties
  14. Lazy Task Properties
  15. Adding Custom Extension To Tasks
  16. Use Command Line Options With Custom Tasks
  17. Automatic Clean Tasks
  18. Parse Files with SimpleTemplateEngine in Copy Task
  19. Copy Files with Filtering
  20. Renaming Files while Copying
  21. Using CopySpec with Tasks
  22. Handle Copying Duplicate Files
  23. Replace Files In Archives
  24. Working with Live Task Collection
  25. Unpacking an Archive
  26. Create Checksums for Archives
  27. Skip Task When Input Empty Using @SkipWhenEmpty Annotation
  28. Inter-Project Artifact Dependencies
  29. Adding Task With Rule Based Model Configuration
  30. Using Optional Ant Task in Gradle

Command line

  1. Execute Tasks with Abbreviations
  2. Pass Command-line Arguments to Build Script
  3. Run a Build Script With a Different Name
  4. Excluding Tasks for Execution
  5. Display Available Tasks
  6. Getting More Help For a Task
  7. Using Continuous Build Feature
  8. Only Show All Tasks In A Group
  9. Check Task Dependencies With a Dry Run
  10. Skip Building Project Dependencies
  11. Continue Build Even with Failed Tasks
  12. Run Task Ignoring Up-to-date Checks
  13. Rerun Incremental Tasks At Specific Intervals
  14. Profiling Information
  15. Stop Build After One Failing Test
  16. Use gradlew for Easy Gradle Execution
  17. Change Gradle Wrapper Script Name
  18. Specify Wrapper Version and Distribution Type From Command Line
  19. Check The Gradle Daemon Status

Java and Groovy

  1. Set Java Version Compatibility
  2. Set Java Compiler Encoding
  3. Enabling Preview Features For Java
  4. Using Maven Toolchains Configuration For Gradle Java Toolchain Resolution
  5. Java Toolchain Configuration Using User Defined Java Locations
  6. Using Gradle for a Mixed Java and Groovy Project
  7. A Groovy Multi-project with Gradle
  8. Run Java Application From Build Script
  9. Running Java Applications from External Dependency
  10. Pass Java System Properties To Java Tasks
  11. Add Support For "Scratch" Files To Java Project
  12. Running Groovy Scripts as Application
  13. Alter Start Scripts from Application Plugin
  14. Running Groovy Scripts Like From Groovy Command Line
  15. Generate Javadoc In HTML5
  16. Create JAR Artifact with Test Code for Java Project
  17. Add Filtering to ProcessResources Tasks
  18. Use Groovy Ruleset File with Code Quality Plugin
  19. Don't Let CodeNarc Violations Fail the Build

Managing Dependencies

  1. Shortcut Notation for Dependencies
  2. Display Dependencies for a Gradle Build
  3. Getting More Dependency Insight
  4. Exclude Transitive Dependency from All Configurations
  5. Adding Dependencies Only for Packaging to War
  6. Manage Dependency Versions With Dependency Constraints
  7. Use bill of materials (BOM) As Dependency Constraints
  8. Defining Plugin Versions Using Version Catalog
  9. Grouping Version Catalog Dependencies Into Bundles
  10. Publish Version Catalog For Sharing Between Projects

Testing Support

  1. Running a Single Test
  2. Running Tests in Parallel
  3. Running All Tests From One Package
  4. Configure Test Task With JVM Test Suite
  5. Set Test Framework Version Using Version Catalog With JVM Test Suite Plugin
  6. Using Spock With JVM Test Suite Plugin
  7. Add Extra Dependencies For Running Tests Using JVM Test Suite Plugin
  8. Show Standard Out or Error Output from Tests
  9. Show More Information About Failed Tests
  10. Specify Spock As Test Framework At Initialization
  11. Continuous Testing For Java Projects

IDE

  1. Delegate Build And Run Actions To Gradle In IntelliJ IDEA
  2. Passing Environment Variable Via Delegate Run Action In IntelliJ IDEA
  3. Customize IDEA Project File Generation
  4. Download Javadoc Files For Dependencies In IDE
  5. Create Shortcut Key To Refresh Gradle Projects In IntellIJ IDEA
  6. Quickly Open Test Report in IntelliJ IDEA
  7. Add Spring Facet To IntelliJ IDEA Module
  8. Configure IntelliJ IDEA To Use Gradle As Testrunner
  9. Enable Compiler Annotation Processing For IntelliJ IDEA
  10. Set VCS For IntelliJ IDEA In Build File
  11. Source Sets As IntelliJ IDEA Modules

Miscellaneous

  1. Parse Output from Exec Invocation
  2. Define A Short Plugin Id For Custom Plugins
  3. Base Plugin Usage
  4. Apply External Script With Plugin Configured Through Buildscript
  5. Init Script for Adding Extra Plugins to Existing Projects
  6. Alter Start Scripts from Application Plugin
  7. Add But Do Not Apply Plugin Using Plugins Block
  8. Set a Project Description
  9. Using and Working with Gradle Version
  10. Rename Ant Task Names When Importing Ant Build File
  11. Use Git Commit Id in Build Script
  12. Get Model Report In Short Format
  13. Getting Project Information Into Rule Based Model Configuration
  14. Set Default Values With Rule Based Model Configuration
  15. Show Hidden Model Objects
  16. Validate Model In Rule Based Model Configuration
  17. Getting Announcements from Gradle Build
  18. Extending DSL
  19. Create Objects Using DSL With Domain Object Containers
  20. Using Nested Domain Object Containers
  21. Distribute Custom Gradle in Our Company

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub