(Quick Reference)

1 Introduction - Reference Documentation

Authors: Luke Daley, Graeme Rocher, Peter Ledbrook, John Engelman

Version: 2.1.1

1 Introduction

The Grails Gradle Plugin provides integration of Grails applications into the Gradle framework. In simple terms, this plugin allows Gradle to build Grails applications in a compatible way with the internal build tooling of the Grails framework.

1.1 Quick Start

The following build.gradle example shows a Grails application configuration in Gradle that matches the default configuration generated by Grails for new projects. Not all the dependencies are required for every application.

buildscript {
    repositories {
    dependencies {

apply plugin: 'grails'

grails { grailsVersion = '2.4.0' // Specifies the Grails version to use groovyVersion = '2.3.1' // Specify the Groovy version to use (should match the version that ships with the above Grails version) springLoadedVersion = '1.2.0.RELEASE' // Specify the Spring Loaded version to use }

repositories { jcenter() grails.central() //Adds the Grails Central Repository for resolving Grails plugins (replaces grailsPlugins(), grailsCentral() from BuildConfig.groovy) }

dependencies { bootstrap 'org.grails.plugins:tomcat:'

compile 'org.grails.plugins:scaffolding:2.0.2' compile 'org.grails.plugins:cache:1.1.1'

runtime 'org.grails.plugins:hibernate:' //or 'org.grails.plugins:hibernate4:' runtime 'org.grails.plugins:database-migration:1.3.8' runtime 'org.grails.plugins:jquery:1.11.0' runtime 'org.grails.plugins:resources:1.2.2'

//runtime 'mysql:mysql-connector-java:5.1.24' //runtime 'org.postgresql:postgresql:9.3.1100-jdbc41'

//Additional resources capabilities //runtime 'org.grails.plugins:zipped-resources:1.0.1' //runtime 'org.grails.plugins:cached-resources:1.1' //runtime 'org.grails.plugins:yui-minify-resources:0.1.5'

//Alternate to the resources plugin //compile 'org.grails.plugins:asset-pipeline:1.5.0'

//Additional asset-pipeline capabilities //compile 'org.grails.plugins:sass-asset-pipeline:1.5.1' //compile 'org.grails.plugins:less-asset-pipeline:1.5.0' //compile 'org.grails.plugins:coffee-asset-pipeline:1.5.0' //compile 'org.grails.plugins:handlebars-asset-pipeline:' }

If you are using a version of Grails that is < 1.3.5 or 1.2.4, the following runtime dependency MUST be added:
runtime 'org.aspectj:aspectjrt:1.6.8'

1.2 Basic Task Reference

Applying the plugin creates the following default tasks in the Gradle project. Task dependencies are declared in brackets.
  • run
  • test
  • war
  • packagePlugin

Additionally, the plugin creates set of default Gradle tasks to mimic the behavior of a standard Gradle Java project. These tasks are wired to the corresponding GrailsTask to provide the behavior.

  • clean
  • test
  • check [test]
  • assemble [war or packagePlugin]
  • build [assemble, check]

Finally, the plugin creates a Gradle Task Rule that allows for execution of any arbitrary Grails script by prefixing the script name with grails-

$ gradle grails-s2-quickstart //Execute the s2-quickstart script from the Spring Security Core plugin

1.3 Change Log


  • Configure war task to use production environment by default - ISSUE-101
  • Handle No signature of method: LinePerThreadBufferingOutputStream.writeTo(LinePerThreadBufferingOutputStream) error - ISSUE-120
  • Add captureOutputToInfo property to GrailsTask which properly captures streams to INFO logger unless error occurs. Disabled by default


  • Renamed default tasks created by plugin: - ISSUE-81
    • run replaces grails-run-app
    • test replaces grails-test-app
    • war replaces grails-war
    • packagePlugin replaces grails-package-plugin
  • Added the reload property GrailsTask to enabled SpringLoaded class reloading for a task. - "ISSUE-84": https://github.com/grails/grails-gradle-plugin/issues/84
  • Configure the static run task and dynamic grails-run-app task to enabled reloading by default.
  • Removed creating the grails-clean task by default. Configure the normal clean task to delete the buildPlugins/ directory.
  • Fix a bug in the IntelliJ IDEA integration where only 1 plugin per configuration was being registered as project source
  • Include bootstrap scope plugins as project source in IntelliJ IDEA
  • Mark test scope plugins directories as Test Source instead of Source in IntelliJ IDEA
  • Support new Maven group name for SpringLoaded library starting with v1.1.5.RELEASE
  • Add support to automatically synchronize app.version and app.grails.version in the application.properties

file to project.version and project.grails.grailsVersion respectively - MAVEN-137

  • Correctly mapped provided scope dependencies to the Grails environment
  • Allow passing of the -PgrailsDebug=true flag to all Grails tasks. - ISSUE-97


  • Fix a bug in setting grails.groovyVersion which resulted in an exception when a dependency tried to include the groovy library.
  • Fix a bug where when a GrailsTestTask is configured with both a set of Task Inputs and a testResultsDir that results in an exception because testResultsDir is a directory but Gradle expects it to be a file.
  • Fix a bug in the task dependency configuration for the clean task that results in Gradle being unable to determine the task graph.
  • Add plugin Zip file or application War file as an output file to the runtime configuration.
  • Configured the default configuration to extend from runtime (similar to Java plugin behavior)
  • Springloaded is only configured for the grails-run-app task (this is what Grails itself does in grailsStart script).
  • Added the init-plugin task to initialize a Grails plugin instead of an application.
  • The grails-run-app task is now available on plugin projects as well (Grails allows this)