PluginExtension.java
The plugin extension file TestSamplePluginExtension.java file is output to the ./src/main/java/synapticloop/plugin/sample directory. This is the object that allows you to pass in (or over-ride) values and options that can then be used by the plugin task.
Looking at the file, you will see the contents:
package synapticloop.plugin.sample;
// - - - - thoughtfully generated by synapticloop gradle-plugin-java-create - - - -
// with the use of synapticloop templar templating language
// (plugin.java.templar)
import org.gradle.api.Plugin;
import org.gradle.api.Project;
public class TestSamplePlugin implements Plugin {
public static final String PLUGIN_NAME = "testSample";
@Override
public void apply(Project project) {
// Register the plugin extension with the project
project.getExtensions().create(PLUGIN_NAME, TestSamplePluginExtension.class);
// Register the plugin task with the project
project.getTasks().create(PLUGIN_NAME, TestSampleTask.class);
}
} Variables used in the generation
TestSamplePlugin.java uses the following variables:
{package}- the command line argument-por--package- This is split on the '
.' character to create the output directory structure. - This becomes the
package {package};declaration at the top of the file
- This is split on the '
{name}- the command line argument-nor--name- This becomes the file name
{name}Plugin.java - This becomes the class declaration
public class {name}Plugin implements Plugin {
- This becomes the file name
{lowerName}- this is generated from the-nor--namecommand line argument. NOTE: this is generated from the{name}variable with its first letter lowercased. (e.g.TestSample->testSample)- This is used to create the plugin extensions for the
build.gradlefile:public static final String PLUGIN_NAME = "{lowerName}";
- This is used to create the plugin extensions for the
Things of note
You probably won't need to change anything in this file, however, a few things to note:
- If you want to add additional tasks and extensions, this is the place to add them. You may have as many tasks as you require - optionally with additional extensions for each task. Alternatively you may only have one extension which can service all of the tasks.
- The name of the file is important - this must match the fully qualified class name that is referenced in the
.propertiesfile (in this case thesynapticloop.plugin.sample.TestSample.propertiesfile)