The first plugin
To make the plugin reusable for all the other projects, Gradle allows you to separate the plugin code and package it in a JAR file. You can include this JAR file in any projects in which you want to reuse this functionality. You can create the standalone project in Java or Groovy. We will proceed with Groovy. You can use any editor (Eclipse, NetBeans, or Idea) to create a plugin. Since our main purpose is to show you how to create a standalone plugin, we will not go into the details of the editor. We will use a simple text editor. To proceed with the standalone plugin, separate the above buildSrc
code into an independent directory. You can name it CustomPlugin
. So, the directory structure will be as follows:
C:/Gradle/Chapter8/CustomPlugin. │ build.gradle │ └───src └───main └───groovy └───ch8 CustomPlugin.groovy
You might be surprised to know why we are creating a build.gradle
file here. With this build.gradle
, we will package...