Member-only story

Building a Gradle Plugin 101

Demystifying the three-step process by learning by example

Oliver Spryn
ProAndroidDev
13 min readDec 10, 2019

--

A black and white picture of an elephant’s head

You can find a Gradle plugin to do just about anything with Java. If you have ever worked on any modern Java application with this build tool, then you are no doubt accustomed to importing and applying plugins to the top of your .gradle files before you can build.

However, in some cases, you’ll encounter a missing link that cannot be adequately addressed by anything on the web. I have encountered this situation several times and was surprised by how easy it was to mend this discrepancy.

For those of you who like to see the end before the beginning, here is the final result of my Gradle plugin.

The Blueprint

There are a few concepts I’ll discuss which do not readily appear in the Gradle documentation but turn out to be quite helpful during testing. Once we have Gradle (the build tool for the plugin itself) and our IDE configured as needed, then we can proceed to build our plugin.

Here is the three-step outline, which I break down in detail later on:

  1. Create an extension to configure the plugin’s behavior
  2. Register the plugin
  3. Create a task to run the plugin

--

--

Published in ProAndroidDev

The latest posts from Android Professionals and Google Developer Experts.

Written by Oliver Spryn

Lead Android Architect at UPMC Enterprises • Instructor • Content Creator • https://oliverspryn.com/

Responses (3)

What are your thoughts?