Creating a plugin in the project source directory

We have defined the plugin and used it in the same build file. We will see how to extract the plugin code from the build file and put it in a separate source file in the project source directory. Also, we will discuss how to test the plugin.

When we define the plugin in our build file, we cannot reuse it in other projects. We now have the definition and usage of the plugin in the same file. To separate the definition and usage, we can create the plugin class in the buildSrc directory of a Gradle project. In a Gradle multi-project, we must use the buildSrc directory of the root project. This means that for a multi-project build, we can reuse the plugin in other projects of the multi-project build. ...

Get Gradle Effective Implementations Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.