O'Reilly logo

Gradle for Android by Kevin Pelgrims

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating your own plugins

If you have a collection of Gradle tasks that you want to reuse in several projects, it makes sense to extract these tasks into a custom plugin. This makes it possible to reuse build logic yourself, and to share it with others.

Plugins can be written in Groovy, but also in other languages that make use of the JVM, such as Java and Scala. In fact, big parts of the Android plugin for Gradle are written in Java in combination with Groovy.

Creating a simple plugin

To extract build logic that is already stored in your build configuration file, you can create a plugin within the build.gradle file. This is the easiest way to get started with custom plugins.

To create a plugin, create a new class that implements the Plugin interface. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required