Wednesday, December 15, 2010

Gradle Build Script (build.gradle) for Writing Gradle Plugins

Gradle is a great build system written in Groovy programming language and that uses build scripts written in Groovy as well.

There are several ways to write a Gradle plugin and the most extensible one (also the most complicated) is to build the plugin as a separate project.

I tried to find documentation on how to do this but I can only find actual guide for writing "embedded" Gradle plugins (the plugins are contained inside buildSrc folder). But to move the plugin out of buildSrc folder and make it independent, you can use a build.gradle build script file like this in your plugin:

apply {
    plugin 'java'
    plugin 'groovy'
    plugin 'maven'
    plugin 'eclipse'

group = 'gradle-plugin-javafx'
version = '0.2.0-SNAPSHOT'

dependencies {
    compile gradleApi()
    groovy localGroovy()

Change group and version properties with your own.

Also, you can leave out applying the 'java', 'eclipse', and 'maven' plugins if you don't use them.