Plugins

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.

About Plugin

This plugin adds textual "about" file to build artifacts created, linking each binary artifact to the build environment and sources it was created with.

The file added contains details about build date and time, last commit made in the project, Java / Gradle versions used for build and some other optional elements like project dependencies, local paths, system and environment variables. If the project was built by Jenkins, TeamCity or Hudson build server then corresponding job details are also added to the file generated.

Full details and examples are available at http://evgeny-goldin.com/wiki/Gradle-about-plugin.

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/

AndroidAnnotations Plugin

This plugin makes use of the Android Plugin to configure AndroidAnnotations for Gradle projects.  Features include:

  • Generation of annotated classes as part of the Java compilation process.
  • Configuration of IntelliJ IDEA-generated files to allow use of AndroidAnnotations inside IDEA.
  • Option to configure the AndroidAnnotations version to use, with support for SNAPSHOT releases.

Details and usage are available at http://wiki.github.com/ealden/gradle-androidannotations-plugin.

Artifactory Plugin

This plugin offers integration of Gradle with Artifactory when running standalone Gradle build scripts. It offers a simple DSL to perform the following as part of your Gradle build:

  • Define default dependency resolution from Artifactory.
  • Define configurations whose artifacts will be published to Artifactory after a full (multi-module) successful build.
  • Capture and publish a build-info object to Artifactory build-info REST API to provide a fully traceable build context.

Full details and examples are available at http://wiki.jfrog.org/confluence/display/RTF/Gradle+Artifactory+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

CloudBees Plugin

Deploys your WAR to RUN@Cloud.
Author: Aleksandr Zhuikov

https://github.com/aleksz/gradle-cloudbees-plugin

A full-fledged plugin that provides support for managing applications and databases on CloudBees RUN@cloud.
Author: Benjamin Muschko
https://github.com/bmuschko/gradle-cloudbees-plugin

CloudFoundry Plugin

This plugin allows you to upload your applications to CloudFoundry. It suports a subset of vmc commands, like getting info from the cloud, pushing, updating, creating a service, starting or stopping an application and more. Documentation is available at https://github.com/melix/gradle-cf-plugin

The plugin is available from Maven Central, but depends on a library which is not, so you need this configuration to get it work:

CodeNarc Plugin

This plugin allows to invoke CodeNarc Groovy code analysis through the "codenarc" task added to your Gradle build. It allows you to configure CodeNarc version used, list of RuleSet files, Groovy source directories, allowed number of Priority 1, 2, 3 violations, etc.

Full details and examples are available at http://evgeny-goldin.com/wiki/Gradle-CodeNarc-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

An alternate Cobertura plugin can be found at 

https://github.com/stevesaliman/gradle-cobertura-plugin

It is licensed under the Apache 2.0 license, and it is the only Gradle cobertura plugin I know of that still runs coverage reports when tests fail.

author: Steven C. Saliman

Cucumber Plugin

author: Samuel Brown
https://github.com/samueltbrown/gradle-cucumber-plugin

Runs Cucumber acceptance tests using cucumber-jvm.

  • Customize output formats and glue directories with built-in task properties
  • Utilize jvm languages by customizing runtime dependencies

Cuke plugin

author: Robert Fischer

Runs cucumber.

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

Cygwin plugin

author: Derianto Kusuma
https://github.com/derianto/Gradle-Cygwin-Toolkit-Plugin

Provides methods to convert UNIX paths to Windows path, Cygwin paths, or file:///-style path using Cygwin's cygpath tool.

Some path incompatibility issues when developing in Cygwin:

  • Gradle's file() method complains when supplied with a UNIX-like cygwin path or a Windows path
  • WAR path in Jetty's context file needs file:///-style path
  • etc.

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/

Dojo Toolkit Custom Build Plugin

author: Craig Swing

Provides the ability to define a build profile and perform a Dojo Toolkit custom build.

https://github.com/cswing/evinceframework-build/wiki/Dojo-Builder-Plugin

Duplicates Plugin

This plugin locates duplicate libraries in Gradle configurations. Duplicate libraries have different coordinates (group or name) but contain an identically named classes, i.e., classes with identical fully qualified names.
For example, configurations below contain a number of legal Gradle dependencies. Yet, some of them are duplicates:

  • "spring-core" is a subset of "spring"
  • "commons-beanutils" repacks some of "commons-collections" classes
  • "junit" repacks a portion of the Hamcrest library

This plugin locates all cases of duplicate classes found in different dependencies and fails the build. Optionally, a warning may be displayed as well as verbose mode turned on that will print out all duplicate classes found.
Full details and examples are available at http://evgeny-goldin.com/wiki/Gradle-duplicates-plugin.

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 (v1.0+) build file:

apply from:'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/
Authors: René Gröschke (Original author), Marcello de Sales (Updates to support Gradle 1.0 and Java 7), Graham Cox (Incorporating Marcello de Sales' efforts into the plugin)

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

Findbugs Plugin

Provides a 'findbugs' task to execute Findbugs analyis.

Author: Andrew Oberstar

Home: https://github.com/ajoberstar/gradle-plugins

See https://github.com/ajoberstar/gradle-plugins/blob/master/README

Fingerprint Plugin

A plugin to add a file's checksum to its name and update references to the file with the new name.
For example:

  • A javascript file foo.js will be renamed to foo-79aa9453.js.
  • A referernce to foo.js in bar.html like <script src="/js/foo.js"></script> will be replaced with <script src="/js/foo-79aa9453.js"></script>
    For more information about assets fingerprinting and caching see Google's PageSpeed caching documentation.

Author: Tal Giat

Home: https://github.com/ReutersMedia/gradle-fingerprint-plugin

See: https://github.com/ReutersMedia/gradle-fingerprint-plugin/blob/master/README.md

Flex Plugin

Build Flex projects using Gradle.

Author: Yennick Trevels & Steven Dick

Home: http://gradlefx.github.com/

See https://github.com/GradleFx/GradleFx/blob/master/README.textile

Gradle-Git Plugin

Git plugins for Gradle.

author: Andrew Oberstar

See https://github.com/ajoberstar/gradle-git

Gradle-Jacoco Plugin

Jacoco plugin for Gradle.

author: Andrew Oberstar

See https://github.com/ajoberstar/gradle-jacoco

Gradle-Git-Dependencies Plugin

Plugin to manage depencencies via Git for Gradle.

author: Baptiste Chatrain

See https://github.com/bat-cha/gradle-plugin-git-dependencies

Grails-Gradle Plugin

Build grails projects using gradle.

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

Grails-Gradle Wrapper

Builds Grails projects by executing a cached copy of Grails.

author: Connor Garvey
See https://github.com/ConnorWGarvey/gradle-grails-wrapper/blob/master/README.md

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

Holy Gradle Plugins

A collection of plugins to support:

  • fetching source code from Mercurial (Hg) and Subversion (SVN) repositories
  • packaging up large numbers of artifacts (e.g. DLLs, PDBs, static libs, and header files) into multiple zips to be published to Ivy repository and subsequently fetching and unpacking these artifacts in the same directory structure
  • storing credentials securely in the Windows Credential Manager, invoking Visual Studio (devenv) 
  • custom deletion rules for cleaning up Artifactory repositories.

https://bitbucket.org/nm2501/holy-gradle-plugins

author: nm2501 (at) google's email service

IvyInstaller Plugin

Install selected dependencies to a repository.

This is particularly useful for users who only have a private repository, and want to benefit from public repositories from time to time. In this case, when a module is missing in the private repository, a call to install let download the module from a public repository not usually used for dependency resolution, and install it and its dependencies in the private repository.

https://bitbucket.org/bwithnet/ivyinstallergradleplugin

IKVM plugin

Generates a .Net assembly from your java project build using IKVM.

https://github.com/Ullink/gradle-ikvm-plugin/

Ivyxml Plugin

Loads dependency definitions from an Ivy dependency file (aka "ivy.xml") into Gradle.

  • Support for configuration inheritance via 'extends'
  • Support for 'transitive' settings on confs and/or dependencies
  • Support for 'classifier's specified using a .../ivy/maven' namespace
  • Optionally set Ivy variables for every Gradle String-type property.
    (user specifieds key prefix which defaults to 'gproj|', e.g. use ${gproj|name}).
  • User-configurable ivy dep file (a real File instance).
  • User-configurable additional Ivy variables.
  • Gradle configuration created for Ivy confs as-needed by default, but may be configured to ignore non-defined Configurations.
  • Unit tested
  • Non supported ivy.xml elements and attributes are documented.
  • Available from Maven Central.

Author: Blaine Simpson. blaine (dot) simpson (at) admc (dot) com
Project Home Page
Product Documentation

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

JavaScript Plugin

A Gradle plugin for building Javascript projects, that understands incremental builds. Has tasks for combination, minification and GZip compression of your JS files, with support for JSHint, JSDoc 3, and props2Js.

author: Eric Wendelin

http://eriwen.github.com/gradle-js-plugin/

JavaFx Plugin

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

Author: Andrew Spina

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

JavaPropFile Plugin

Loads String properties from specified Java Properties files into a Map, your Gradle Project, or specified Gradle extension object. Expands variable ${reference}s in supplied Strings or text files. Provides a utility Gradle Copy Filter without the limitations and performance problems with Gradle's built-in filters.

What's wrong with Gradle's "gradle.properties" system? You are restricted to a single properties file in your home directory and one for each project directory, all with mandated name. If you want to separate your properties into shared properties and personal properties, as is a very good practice, you can't. If you want to set the value of a property to the value of a previously set property or a system property, or some mix of literals and those, you can't. If you want to set a Boolean or File value, you will have to change your Gradle Groovy code to convert.

  • Thoroughly unit tested. Over 80 unit tests.
  • Supports nested property references ${like.this}, just like Ant and Log4j property files.
  • Can ${reference} or set properties on a Map, the Gradle Project, specified extension objects, or arbitrarily nested properties under them. For example, you can set compile.Java.options.debug.
  • Optionally supports Java system property references in the same way, just like Ant and Log4j property files, but with user-specified namespace prefix to avoid collisions and pollution.
  • Optionally supports setting of Java system properties in the same way.
  • Can toggle on typeCasting, which allows you to assign properties of arbitrary types with property file entries like "javac.debug{Boolean)=true", "target.textFile(File)=${java.io.tmpdir}/file.txt", and nulls like "lunch()=". Arrays and all Collection implementations are also supported.
  • Ability to overwrite properties (changing values of existing properties) is configurable.
  • Behavior if unresolvable nested references encountered (like "newvar=x${undefinedVar}y") is configurable. You may abort (throw), leave the literal (like "${undefinedVar}", what Ant and Log4j do IIRC), or replace the "${undefinedVar}" with an empty string.
  • Available from Maven Central.

Author: Blaine Simpson. blaine (dot) simpson (at) admc (dot) com
Project Home Page
Product Documentation

JAXB Plugin

This plugin generates Java classes from given XML schemas using the xjc compiler.

Authors: Stian Hegglund & Stig Kleppe-Jørgensen
Home: https://github.com/stianh/gradle-jaxb-plugin

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

JDepend Plugin

Provides a 'jdepend' task to execute JDepend analysis.

Author: Andrew Oberstar

Home: https://github.com/ajoberstar/gradle-plugins

See https://github.com/ajoberstar/gradle-plugins/blob/master/README

Jenkins Plugin

Provides functionality to programmatically configure Jenkins jobs via gradle.  Allows for templates that can be used to generate multiple jobs off of a single template using MarkupBuilder closures.

Home: https://github.com/ghale/gradle-jenkins-plugin/wiki

jOOQ Plugin

jOOQ generates a simple Java representation of your database schema. Every table, view, stored procedure, enum, UDT is a class. This plugin performs code generation as part of the Gradle build.

Author: Ben Manes

Home: https://github.com/ben-manes/gradle-jooq-plugin

jsvc plugin

Plugin to facilitate running projects which use jsvc.

Author: Ahsan Rabbani

Home: https://github.com/xargsgrep/gradle-jsvc-plugin

Kotlin plugin

Allows to compile Kotlin sources and tests.

Author: Goldin Evgeny

Home: http://evgeny-goldin.com/wiki/Gradle-Kotlin-plugin

Launch4J Plugin

Creates a Windows .exe executable for a java application using launch4j

Author: Philip Crotwell

http://code.google.com/p/gradle-launch4j

MacAppBundle Plugin

Creates a Mac OSX .app application for a java application

Author: Philip Crotwell

http://code.google.com/p/gradle-macappbundle

MSBuild plugin

MSBuild project file parsing and execution.

https://github.com/Ullink/gradle-msbuild-plugin/

NuGet Plugin

This plugin allows to execute NuGet.exe from a gradle build.
It also supports pack & push commands through built-in tasks nugetPack & nugetPush.

Home: https://github.com/Ullink/gradle-nuget-plugin

PIT Plugin

Provides an ability to perform mutation testing and calculate a mutation coverage with PIT.

Author: Marcin Zajączkowski

URL: http://gradle-pitest-plugin.solidsoft.info/

PMD Plugin

Provides a configurable 'pmd' task to execute PMD analysis.

Author: Andrew Oberstar

Home: https://github.com/ajoberstar/gradle-plugins

See https://github.com/ajoberstar/gradle-plugins/blob/master/README

Properties Plugin

Author: Steve Saliman

The properties plugin enhances the way Gradle defines the project properties.  By default, Gradle looks at 3 locations for properties:

  1. gradle.properties in the project directory
  2. gradle.properties in the user's .gradle directory
  3. The command line via -P arguments.

The properties plugin adds 2 alternate and configurable files to the mix.  With the properties plugin, the sequence is:

  1. gradle.properties in the project directory
  2. gradle-${environmentName}.properties in the project directory
  3. gradle.properties in the user's .gradle directory
  4. gradle-${gradleUserName}.properties in the user's .gradle directory
  5. The command line via -P arguments.

This allows developers an easy way to pull environment specific values out of files like log4j.properties into a set of property files, one for each build environment.  The developer can then specify at build time which environment for which they're building.

They can also take properties that span projects, but change from client to client, and put them in client based property files in their .gradle directory.

When the plugin loads properties, it creates a project.ext.filterTokens property which can be used during file copies to get the right values into files as it is building.

The plugin is Apache 2.0 licensed, and available on Maven Central.  Full details and documentation is available at https://github.com/stevesaliman/gradle-properties-plugin

Protocol Buffers Plugin

The Protobuf plugin provides protobuf compilation to your project.

Author: Alex Antonov

Home: https://github.com/aantono/gradle-plugin-protobuf

See https://github.com/aantono/gradle-plugin-protobuf/blob/master/README.md

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/

R Plugin

A plugin for creating packages in the R programming language.

source and some documentation:  https://github.com/jamiefolson/gradle-plugin-r

RJava Plugin

A plugin for creating packages in the R programming language for Java source code with rJava and annotations.

source and some documentation:  https://github.com/jamiefolson/JAnnotateR

Release Plugin

This plugin provides a maven-like release process that works for Bazaar, Git, Mercurial, and Subversion.

Author: Eric Berry & Evgeny Goldin

Home: https://github.com/townsfolk/gradle-release

Repositories Plugin

This plugin extends the gradle repository class with some helpers to access download pages from various projects as artifact repositories.
It supports download pages from the following sites Sourceforge/Googlecode/GitHub and also adds NuGet service as artifact repository.

Home: https://github.com/Ullink/gradle-repositories-plugin

SublimeText Plugin

Allows gradle to create a Sublime Text 2 project file.

Author: Philip Oliver-Paull

http://github.com/phildopus/gradle-sublimetext-plugin

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/

TeamCity plugin

Allows to build and archive TeamCity plugins.

Author: Goldin Evgeny

Home: http://evgeny-goldin.com/wiki/Gradle-TeamCity-plugin

Templates Plugin

The gradle-templates plugin provides basic functionality for bootstrapping projects to work with Gradle's default settings.

For example, there is a 'createJavaProject' task which will create a new Java project that is buildable using Gradle.

Author: Eric Berry

Home: https://github.com/townsfolk/gradle-templates

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.)

Vaadin Plugin

The gradle-vaadin-plugin is available at github: https://github.com/johndevs/gradle-vaadin-plugin.
The README file contains a detailed description on how to use it and there is even a screencast available about this plugin at http://www.youtube.com/watch?v=opjN3xlQ9Xk

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

Obsolete
Per Jörn Huxhorn, the author, this plugin is now obsolete since Gradle now comes with the Signing "Standard" plugin.

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

org.linkedin plugins

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

Ubuntu Packager Plugin

A plugin for creating native ubuntu packages for use with the apt system.

See the sources for usage instructions and an example project at https://github.com/sgo/ubuntu-packager-plugin

RPM Plugin

A plugin for creating RPM packages.

source and some documentation:  https://github.com/TrigonicSolutions/gradle-rpm-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
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Aug 08, 2011

    I wanted to add a link to my gradle-templates plugin, but I can't seem to edit this page. So, I'm adding a comment instead.

    The gradle-templates plugin is provides basic functionality for bootstrapping projects to work with Gradle's default settings.

    Eg. There is a 'createJavaProject' task which will create a new Java project that is buildable using gradle.

    See the Launchpad project page for information.

    1. Aug 09, 2011

      I don't see anything wrong with your permissions. After logging in, do you see an "Edit" button in the upper right corner of the page?

      1. Aug 09, 2011

        Yes, I see the "Edit" button, and I'm able to edit other pages. It just seems to be a problem with this one. When I click the edit button, I get a blank text-area - almost as if it's a new page and there isn't any content.

        Here's a screenshot of what I see:

        http://tellurianring.com/images/edit_plugins.png

        1. Aug 09, 2011

          Strange. What happens if you resize the text area or click the "Wiki Markup" or "Preview" tab?

        2. Aug 09, 2011

          Meanwhile I've added your plugin to the page.

          1. Aug 09, 2011

            Many thanks! I tried resizing it with the same results.

            Firebug isn't showing any real errors, but I do see this in the console:

            Failed to run init function: message: regular expression too complex, fileName: http://wiki.gradle.org/s/en/2160/1/1.9.8/_/download/batch/com.atlassian.confluence.ext.newcode-macro-plugin:syntaxhighlighter/com.atlassian.confluence.ext.newcode-macro-plugin:syntaxhighlighter.js, lineNumber: 17, stack: ([object RegExp],"")@http://wiki.gradle.org/s/en/2160/1/1.9.8/_/download/batch/com.atlassian.confluence.ext.newcode-macro-plugin:syntaxhighlighter/com.atlassian.confluence.ext.newcode-macro-plugin:syntaxhighlighter.js:17

            And I see the pages content in Firebug's console, very strange. Other odd thing is the "Wiki Markup", and "Preview" tabs don't work.

            Thanks again!

            1. Aug 09, 2011

              OK, I can reproduce this with Firefox 4/5. Seems to be a problem with Confluence and Firefox.