In-depth Gradle plugin development

Writing and distributing reusable, maintainable and tested build logic

Summary

Gradle build scripts should be as declarative as possible to avoid one-off logic that is hard to understand and maintain. The plugin mechanism empowers build engineers to write reusable, maintainable and tested build logic.

This practical course catapults you from zero to plugin expert by delivering best practices and hands-on experience. By the end of this course, you will understand the full development lifecycle needed to implement, test, document and publish your own Gradle plugins.

Duration

8 hours

What you’ll learn

  • Understand the problems Gradle plugins can solve
  • Techniques and best practices used to implement a Gradle plugin
  • How to test, document and deliver a Gradle plugin
  • Ensure the best interoperability of plugin for use with the Groovy and Kotlin DSL

Prerequisites

  • Working knowledge of the programming language Java
  • Familiarity with Gradle concepts and the DSL
  • Optional: Project automation techniques like testing and Continuous Integration

Curriculum

  • Introduction
    • Making your build logic maintainable & reusable
    • Typical plugin use cases
    • The different types of plugins in Gradle
    • The typical plugin development lifecycle
    • Our demo-plugin and the problems it will solve
  • Implementing a plugin
    • Picking a suitable JVM language to implement a plugin
    • Implementation jumpstart with the plugin development plugin
    • First steps in writing a binary plugin
    • Providing a plugin identifier
    • Hands-on exercise: Implementing a simple plugin
    • Hiding imperative logic in custom tasks
    • Lazy evaluation of user-provided configuration
    • Hands-on exercise: Enhancing the plugin by a task implementation
    • Exposing a custom DSL to control runtime behavior
    • Hands-on exercise: Writing an extension
    • Tips, tricks and best practices
    • Hands-on exercise: Applying plugin best practices
  • Testing the plugin functionality
    • Different types of tests
    • TestKit: the toolkit for testing plugins
    • Implementing and executing functional tests with TestKit & JUnit 5
    • Running tests from the IDE
    • Hands-on exercise: Writing and executing a functional test with TestKit
  • Packaging and publishing plugins
    • Versioning the plugin binary
    • Publishing to a binary repository
    • Publishing to the Gradle plugin portal
    • Hands-on exercise: Publishing and applying from a build
  • Documenting plugins
    • How does documentation help consumers of a plugin?
    • Creating helpful Javadoc documentation
    • Documenting plugin functionality
    • Auto-tested, embedded example source code
    • Hosting documentation
    • Hands-on exercise: Building effective documentation
  • Continuous Integration for plugins
    • Using Travis CI for Open Source plugins
    • Using Jenkins for enterprise plugins
    • Hands-on exercise: Setting up a build pipeline
  • Summary and Q&A

Ready? Let's talk!

We're here to help. If you'd like to learn more, get in touch with us.