Gradle In-Depth

Learn everything you need to know about Gradle in three days.

Description

The Gradle In-Depth training course is an extensive hands-on three day Gradle training course for build masters and developers who are authoring their builds. Participants will learn how to use the Gradle build system to substantially increase their productivity. This Gradle training class first runs through some Groovy fundamentals and then moves quickly into thorough in-depth coverage of the Gradle build system.

Participants will spend a significant portion of the class with their hands on the keyboard, learning by doing, working through lab exercises designed to build on the presented material and explore the depths of Gradle. This class can take you from complete newcomer status to Gradle competence. Due to the in-depth treatment of the topics it is also very suitable for people who have experience working with Gradle. The class will be delivered by a Gradle Core Developer which gives you access to the deepest Gradle knowledge available. No question will remain unanswered.

Duration

3 days

Objectives

Once the training is complete participants will:

  • Learn the basics of Gradle and Groovy
  • Learn how Gradle integrates with Android
  • Write your own Gradle plugins
  • Integrate with Ant and Maven
  • Learn about copy and archive tasks in Gradle
  • Work with a powerful file system API
  • Build migration best practices
  • Learn how to use the Gradle performance
  • Learn how to build Java applications
  • How to efficiently move away from your current build environment
  • Learn how to deal with complex build requirements
  • Learn how to deal with large multi module builds

Audience

New and experienced users are encouraged to attend Gradle In-depth. This class has something for every level of Gradle user.

Prerequisites

This course assumes a good understanding of the Java language. Some code is initially easier to understand if you also have a basic understanding of the Groovy language. But due to Groovy’s similarity to Java, Groovy is not a prerequisite. There will be a very short introduction to Groovy at the beginning of the course.

Course Outline

Day 1: Introduction to Gradle

Overview

  • About Gradle
  • Gradle Documentation and Resources
  • Groovy Documentation and Resources
  • Gradle Best Practices
  • Using the Gradle Wrapper
  • Gradle Daemon and command line options
  • Lab: Invoking Gradle
  • Lab: A look at the class project

Gradle Building Blocks

  • Gradle Build Scripts
  • Defining Tasks
  • Executing Tasks
  • Built-in Tasks
  • Build Lifecycle
  • Incremental builds and working with files
  • Working with Archives
  • Lab: Exercises with Gradle basics

Java Plugin

  • Source layout conventions
  • Tasks added by the Java plugin
  • Built-in support for JUnit/TestNG tests
  • Lab: Exercises with the Java Plugin

C++ Plugin

  • Software Component Model
  • Source layout conventions
  • Tasks added by the C++ plugin
  • Lab: Exercises with the C++ Plugin

Dependency Management Basics

  • Defining repositories
  • Defining dependencies
  • Transitive dependencies
  • Excluding troublesome dependencies
  • Forcing the use of particular versions
  • Dynamic/changing dependencies
  • Publishing artifacts
  • Lab: Exercises with dependencies and repositories

Multi-project builds

  • Defining a multi-project build
  • Configuration injection
  • Project dependencies and partial builds

Wrap Up

  • Where to get more help
  • Latest Gradle Features
  • Built-in Plugins
  • Community Plugins

Days 2 and 3: Advanced Gradle Fundamentals

Plugins

  • What are Gradle plugins?
  • The role of plugins
  • Packaging and distributing plugins
  • Review of core plugins

Working with files

  • The file tasks (e.g. Copy, Sync)
  • Filtering, excluding,
  • aggregating, renaming
  • Working with CopySpecs
  • Expanding and making archives (zip, tar etc.)
  • The Gradle file APIs
  • Best practices for working with files

Ant Integration

  • Gradle compared to Ant
  • When to utilize Ant in Gradle
  • Using Ant tasks in Gradle builds
  • Importing Ant builds
  • Migrating from Ant to Gradle

Dependency Management

  • Terminology
  • Repositories, metadata and transitive dependencies
  • Dependency configurations
  • Declaring dependencies
  • Customizing dependency resolution & conflict-management
  • Publishing artifacts (Maven & Ivy)

Extending the model

  • Extending existing objects
  • Object extensions
  • Object containers & configuration rules

Task inputs & outputs

  • The power of the input/output model
  • Describing inputs and outputs
  • Incremental builds
  • Inferring task dependencies

The Java plugin

  • Source sets
  • Project conventions
  • Automated testing
  • Building JARs

Multiproject builds

  • Defining a multiproject build
  • Avoiding duplicate configuration with configuration injection
  • Inter project dependencies
  • Downstream and upstream partial builds

The build runtime

  • Extending all builds with init scripts
  • Init script locations
  • Using the Gradle wrapper
  • Customizing the Gradle distribution with init scripts