gradle-plugin-java-create

We love gradle, we love plugins - but we wanted to be able to write them in java in a much quicker way.

So, we created this scaffolding generator for gradle plugins in java!

This project also provides the documentation, so that you understand what is going on and are able to extend the plugin to do whatever you want it to. Rather than building yet another plugin (which we wanted to), we decided to build this plugin builder - as a way of sharing the knowledge of how to build plugins, and as a final test - use it as a way to build the next plugin!

Quick Start

To get started quickly you will need to download the jar from the GitHub releases page. We recommend that you get the latest release.

Once you have downloaded the jar, try:

java -jar gradle-plugin-java-create-<version>-all.jar 

You will be presented with a (hopefully) helpful usage message:

usage: gradle-plugin-java-create
 -a,--artefact <arg>         The artefact that this will be published under (e.g. the github user/org name or the gradle
                             plugins username)
 -d,--desc <arg>             The description for the gradle plugin (free text description)
 -dg,--display-group <arg>   The display group for the gradle plugin (the group that the plugin will be listed under for
                             'gradle tasks')
 -dn,--display-name <arg>    The name to display on the gradle plugins site
 -jp,--java-package <arg>    The java package for the plugin (java dot '.' delimited package name)
 -n,--name <arg>             The name of the gradle plugin (java class name CamelCase - __MUST__ not end in the word
                             'Plugin')
 -t,--tags <arg>             A comma ',' separated list of tags for the plugin that is displayed on the gradle plugins
                             site

ALL options are required

Example

java -jar gradle-plugin-java-create-<version>-all.jar \
    -a synapticloop \
    -d "a simple test plugin" \
    -dg "Sample" \
    -dn "Synapticloop test sample plugin" \
    -jp synapticloop.plugin.sample \
    -n TestSample \
    -t test,plugin

This will then generate the following files:

./src/main/resources/META-INF/gradle-plugins/synapticloop.testSample.properties
this file is used by the gradle system to identify that it is actually a gradle plugin and designates the plugin's implementation class.
./src/main/java/synapticloop/plugin/sample/TestSamplePlugin.java
This is the plugin file which registers the extension that the task relies on and the tasks that the plugin provides
./src/main/java/synapticloop/plugin/sample/TestSamplePluginExtension.java
This is the extension file which allows you to set variables or over-ride defaults for the task.
./src/main/java/synapticloop/plugin/sample/TestSampleTask.java
This is the task which does all of the work.
./build.plugin.initial.gradle
This is the initial build file which you may use to publish the plugin to the local maven repository for testing
./build.plugin.gradle
This is the testing gradle build file which allows you to test out iterations of the plugin using the local maven repository