Configuring plugins
So far, we have seen how to create a standalone custom plugin and include it in another project build file. Gradle also allows you to configure plugin properties and customize them as per your project's need. You have already learned how you can customize the source code location and test code location in a java
plugin. We will see an example of how you can replicate the same behavior in your custom plugin. To define plugin properties, you need to create one additional extension
class and register the class into your plugin
class. Let's say we want to add the location
property to the plugin. Create the CustomPluginExtension.groovy
class as follows:
package ch8 class CustomPluginExtension { def location = "/plugin/defaultlocation" }
Now, register this class to your plugin
class:
class CustomPlugin implements Plugin<Project> { void apply(Project project) { def extension = project.extensions.create("customExt",CustomPluginExtension) project.task('task1') <<...