The following is the first few sections of a chapter from The Busy Coder's Guide to Android Development, plus headings for the remaining major sections, to give you an idea about the content of the chapter.


Writing a Gradle Plugin

Gradle is very extensible, from Groovy scripting code in your build.gradle file all the way up to dedicated Gradle plugins. The more you want to reuse a particular piece of functionality, or the more sophistication you want in your custom builds, the more likely it is that a Gradle plugin will be the right solution.

Sometimes, a Gradle plugin will be focused mostly on tailoring the build process itself. However, a Gradle plugin could be simply an integration point for a tool that could be used in other ways (e.g., command-line API) that would not otherwise require Gradle. This is particularly true for tools that work across IDEs, where you put most of the core logic into a core set of tool code and have thin build system plugins that bridge between the build system or IDE and the tool itself.

In this chapter, we will look at the basics of setting up a Gradle plugin. The plugin that we develop in this chapter will not do much of anything. The next chapter, however, creates a Gradle plugin that generates Java code, building on what we explore here.

Prerequisites

This chapter will make the most sense if you have read the preceding chapters on Gradle, particularly the chapter on Gradle tasks.

Customizing a Gradle Build

The preview of this section is unavailable right now, but if you leave your name and number at the sound of the tone, it might get back to you (BEEEEEEEEEEEEP!).

Some Use Cases for a Custom Plugin

The preview of this section was the victim of a MITM ('Martian in the middle') attack.

Writing a Plugin

The preview of this section is off trying to sweet-talk the Khaleesi into providing us with a dragon.

Distributing the Plugin

The preview of this section was last seen in the Bermuda Triangle.

Using the Plugin

The preview of this section apparently resembled a Pokémon.

Creating a Real Plugin

The preview of this section is [REDACTED].