Skip to end of metadata
Go to start of metadata


This page gathers information on plugins that you can use in your Gradle build scripts to enhance it with new capabilities.

If you are looking for plugins that allows other 3rd party tools to work with Gradle (e.g. make your IDE understand Gradle build, or allow your CI server to run Gradle builds) please see the Cookbook.

Android Plugin

This plugin enables the creation of Android applications using Gradle, with all of the power and flexibility you’ve come to expect from Gradle.

Features of the Android plugin include:

  • Compile, package, and install Android applications. (Including handling of Android resource files.)
  • Sign application packages using the default debug key, or with a release key for publication to Android Market.
  • Incorporation of ProGuard to ensure that applications have minimal memory footprint.
  • Create Android applications in Scala (and possibly Groovy or Clojure).

The Android plugin fully integrates into the Gradle build lifecycle by extending the Java plugin. Furthermore, the incorporation of ProGuard into the build not only ensures that Android application packages are small and tight, it also trivially enables the use of Scala for Android application development simply by incorporating the existing Scala plugin into the build. ProGuard will include only those classes from the Scala library that are actually used by your Android application, resulting in an application package that is as small as possible.

Full details are available at http://wiki.github.com/jvoegele/gradle-android-plugin/

AspectJ plugin

This plugin adds aspectj support to the java plugin. Additional configurations (ajc, inpath and aspects) are used to configure the required dependencies. Furthermore it adds ajdt support to the gradle eclipse plugin. The plugin is available at http://github.com/breskeby/gradleplugins/blob/0.9-upgrade/aspectjPlugin/aspectJ.gradle

The plugin can be used by adding the following line to your gradle (v0.9+) build file:

apply url:'http://github.com/breskeby/gradleplugins/raw/0.9-upgrade/aspectjPlugin/aspectJ.gradle'

An example is available at http://github.com/breskeby/gradleplugins/tree/0.9-upgrade/aspectjPlugin/examples/
For further explanations have a look at http://www.breskeby.com/2010/02/using-gradle-with-aspectj/ and http://www.breskeby.com/2010/03/speed-up-your-build-with-gradle/
author: René Gröschke

Cargo Plugin

A Gradle plugin that provides deployment capabilities to local and remote containers via Cargo.

Author: Benjamin Muschko

Home: https://github.com/bmuschko/gradle-cargo-plugin

ClassLoader plugin

tbd. short info on what is the purpose ?

author: Robert Fisher
how-to available at: http://github.com/RobertFischer/gradle-plugins/blob/master/README.md

Clojuresque plugin

Formerly known as clj-gradle plugin.

author: Meikel Brandmeyerhttp://bitbucket.org/kotarak/clojuresque

Cobertura Plugin

Adds Cobertura coverage reporting tasks for Gradle.

https://github.com/valkolovos/gradle_cobertura/wiki

author: Val Kolovos

Cuke plugin

author: Robert Fischer

Runs cucumber.

https://github.com/RobertFischer/gradle-plugins/

DepNames plugin

author: Robert Fisher

Provides the ability to keep external dependency names and versions in one location, and use them throughout a number of projects. By assigning a Java identifier as a key and a configuration spec as a value in a properties file, that identifier becomes available in the dependencies configuration block.

http://enfranchisedmind.com/blog/posts/gradle-depnames/

Emma plugin

This plugin adds Emma code coverage reporting to the java plugin test task. It can be used in single- or multiproject builds. The plugin is available at http://github.com/breskeby/gradleplugins/tree/master/emmaPlugin

The plugin can be used by adding the following line to your gradle (v0.9+) build file:

apply url:'http://github.com/breskeby/gradleplugins/raw/master/emmaPlugin/emma.gradle'

An example is available at http://github.com/breskeby/gradleplugins/tree/master/emmaPlugin/sample/
For further explanations have a look at http://www.breskeby.com/2010/04/add-emma-code-coverage-reporting-to-your-gradle-build/
author: René Gröschke

Exec plugin

Allows to execute shell commands.

author: Robert Fisher
how-to available at: http://github.com/RobertFischer/gradle-plugins/blob/master/README.md

Env plugin

Allows easy access to environment variables.

author: Robert Fisher
how-to available at: http://github.com/RobertFischer/gradle-plugins/blob/master/README.md

Google App Engine (GAE) Plugin

A Gradle plugin that provides tasks for uploading, running and managing Google App Engine Java projects.

Author: Benjamin Muschko

Home: https://github.com/bmuschko/gradle-gae-plugin

Gaelyk Plugin

A Gradle plugin that provides tasks for managing Gaelyk projects.

Author: Vladimír Oraný, Benjamin Muschko

Home: https://github.com/bmuschko/gradle-gaelyk-plugin

Grails-Gradle Plugin

Build grails projects using gradle.

author: Peter Ledbrook
See https://github.com/grails/grails-gradle-plugin

Groovy-eclipse Plugin

Uses the groovy eclipse compiler for Java and Groovy compilation instead of the default javac/groovy compilers.

author: Adam Murdoch
See https://github.com/adammurdoch/gradle-groovy-eclipse-compiler#readme

GWT Plugin

author: Markus Kobler

http://github.com/markuskobler/gwt-gradle-plugin

IzPack Plugin

A Gradle plugin that provides support for packaging applications for the Java platform via IzPack.

Author: Benjamin Muschko

Home: https://github.com/bmuschko/gradle-izpack-plugin

Javascript Library Plugin

A Gradle plugin for building Javascript Libraries. Allows for source file combination - combining smaller js files into larger ones for user download, and source file filtering to remove unwanted debug code from artifacts.

author: Eric Berry

https://launchpad.net/gradle-jslib

JavaFx Plugin

A Gradle plugin for building JavaFx source. Based on Clojuresque.

Author: Andrew Spina

Home: http://code.google.com/p/gradle-plugin-javafx/

jDocbook Plugin

Author: Steve Ebersole

Home: http://github.com/sebersole/jdocbook-core

Please read this post: http://gradle.1045684.n5.nabble.com/jDocBook-for-Gradle-td1432002.html#a1432002

OneJar plugin

author: Robert Fischer

Provides tasks to generate a single executable jar containing dependencies. Uses one-jar under the hood. The resulting jar file will be next to the standard jar, but with '-fat' attached to the name.

https://github.com/RobertFischer/gradle-plugins/

SvnKit Plugin

A Gradle plugin to connect a project to a Subversion repository using the SvnKit library (http://www.svnkit.com/)

Author: Walter Di Carlo

Home: http://code.google.com/p/gradle-wdc-plugins/

Tomcat Plugin

A Gradle plugin supporting deployment of your web application to an embedded Tomcat web container.

Author: Benjamin Muschko

Home: https://github.com/bmuschko/gradle-tomcat-plugin

Xslt Plugin

A Gradle plug-in that defines a custom task type that can be used to transform one or more documents using XSLT.

Author: Paul Speed

The last version as of this post can be found here: http://filament.svn.sourceforge.net/viewvc/filament/trunk/gradle-plugins/xslt.gradle?revision=445

Some documentation exists in the header of that plug-in file but here is an example usage from the header:

task checkstyleReport(type: Xslt, dependsOn: check) {
    source project.checkstyleResultsDir
    include '*.xml'
    destDir = project.checkstyleResultsDir
    extension = 'html'

    stylesheetFile = file( 'config/checkstyle/checkstyle-noframes.xsl' )
}

The above definition requires that the specified XSL file be copied in with the other checkstyle configuration files. (The file in the example is part of the checkstyle distribution.)

Workspace Plugin

A Gradle plugin to:
- load project properties from a CSV file
- create sub-project's build.gradle file from sections of a central workspace file
- add conditional project dependencies

Author: Walter Di Carlo

Home: http://code.google.com/p/gradle-wdc-plugins/

PGP Plugin

This plugin won't be supported anymore since Gradle includes a similar but better implementation itself.

See "Signing plugin" in the documentation.

This plugin creates PGP signatures for all Maven artifact files as required for inclusion in the Central Maven Repository.
Description and example are contained in the README and will be enhanced over time.

Current version is 0.0.3.

Add the following to your build script:

You can then apply the plugin:

Configuration is either done by the pgp convention like this:

or using gradle properties:

Information in the pgp convention overrides gradle properties! Because of this, it is possible to sign sub-modules using different keys in case of a multi-module project.

Instead of specifying the password using either convention or gradle property you should simply omit it.

In that case, the user will be asked for the password at build time - which is the most secure option.

Author: Jörn Huxhorn

Home: http://github.com/huxi/huxi-gradle-plugins

Protocol Buffers Plugin

Gradle build plugin to handle Protocol Buffers automated code generation and compilation

Author: Alex Antonov
Home: http://code.google.com/p/gradle-plugin-protobuf

org.linkedin plugins

* Author: Yan Pujante
* Available at https://github.com/linkedin/gradle-plugins in source form
* Latest version (1.5.0) available at maven central: org.linkedin:org.linkedin:org.linkedin.gradle-plugins:1.5.0
* Check out the file README.md for details

a. org.linkedin.userConfig

Plugin which attempts to load user configuration from a set of various files and make it available to all gradle build files as a 'userConfig' object (instance of groovy.util.ConfigObject).

Example of usage

b. org.linkedin.spec

This plugin reads a file called project-spec.groovy and makes it available in all build files as a 'spec' object (instance of java.util.Map)

Example of usage

c. org.linkedin.repository

This plugin allows you to externalize repository configuration and override it with your own defaults. It tries to read a set of files and make it available to your build script as a 'allRepositories' object.

Example of usage

d. org.linkedin.release

This plugin adds 'release' and 'publish' tasks to easily release (in a local repo) or publish (in a remote repo). It automatically handles sources / javadoc / groovydoc. The repositories are configured using the 'org.linkedin.repository' plugin. The plugin is 'snapshot aware' and can be used with the org.linkedin.spec plugin to easily switch between snapshot and non snapshot releases.

Example of usage

e. org.linkedin.cmdline

This plugin adds the following tasks to create a packaged command line (tgz by default).
* package-assemble: Assembles the package (exploded)
* package: Create the package
* package-install: Install the package (locally)
* package-clean-install: Cleans the (previously) installed package

This plugin automatically copies src/cmdline/resources into the root of the tar ball and deploy all dependencies (jars) in the lib folder (of the tar ball). This plugin can be used with the org.linkedin.release plugin to release/publish the package.

JSLint Plugin

A plugin to enable static analysis of JavaScript code using JSLint.

author: Kelly Robinson

source: https://github.com/kellyrob99/gradle-jslint-plugin

Versions Plugin

A plugin to discover dependency updates.

author: Ben Manes

source: https://github.com/ben-manes/gradle-versions-plugin

Writing Custom Plugins

See: Writing Custom Plugins chapter in Gradle User Guide

Example of a simple custom task within buildSrc

In your build.gradle, add

and put the class in buildSrc/src/main/groovy

CopyToLib.groovy

and then you can do

gradle copyToLib

Example of a simple custom plugin within buildSrc

This plugin creates a java file with a getter for the version, group and name derived from the build.gradle file. Such a class can be useful for printing the current version of a application, and you don't want the actual version in two places as you will forget to change one of them at release time.

In your build.gradle, add

and put the class below in buildSrc/src/main/groovy

VersionClass.groovy

and then you can do

gradle makeVersionClass

to generate a java class with the version from the build.gradle.

Also, gradle will automatically compile this class and add it to the jar default jar along with the normal main java code.

Obviously, this whole function might be better accomplished by simply printing the project.version into a text file
in the resources directory, but this serves as a basic, but non-trivial, plugin example as well as an example of how to deal with generated java code.

Building an external plugin (outside buildSrc)

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

Labels
  • None