GithubHelp home page GithubHelp logo

grails-gradle-plugin's Introduction

Grails Gradle Plugin

This plugin for Gradle allows you to build Grails projects. To use it, simply include the required JARs via buildscript {} and 'apply' the plugin:

buildscript {
  repositories {
    jcenter()
  }
  dependencies {
    classpath "org.grails:grails-gradle-plugin:2.1.2"
  }
}

version "0.1"
group "example"

apply plugin: "grails"

repositories {
  grails.central() //creates a maven repo for the Grails Central repository (Core libraries and plugins)
}

grails {
  grailsVersion = '2.4.3'
  groovyVersion = '2.3.7'
  springLoadedVersion '1.2.0.RELEASE'
}

dependencies {
  bootstrap "org.grails.plugins:tomcat:7.0.50" // No container is deployed by default, so add this
  compile 'org.grails.plugins:asset-pipeline:2.1.3' // Just an example of adding a Grails plugin
}

You must specify the grails.grailsVersion property before executing any Grails commands.

The 'grails.groovyVersion' property is a convenience for Grails 2.3.0, it may not work correctly in earlier versions, so it's best to not use it with version pre-2.3.0. Declaring grails.groovyVersion will configure a Gradle ResolutionStrategy to modify all requests for groovy-all to be for the version specified. Additionally, the ResolutionStrategy will change all requests for groovy to be groovy-all

The grails-gradle-plugin will populate the bootstrap, compile, and test classpaths with a base set of dependencies for Grails. You need to provide a container plugin such as 'tomcat' to the bootstrap classpath to enable the run-app command.

Warning If you're using a pre-1.3.5 or pre-1.2.4 version of Grails, you'll need to add this runtime dependency to your project's build file:

runtime org.aspectj:aspectjrt:1.6.8

Once you have this build file, you can create a Grails application with the 'init' task:

gradle init

Initialize a new Grails plugin project by running:

gradle init-plugin

The plugin creates standard tasks that mimic the Java lifecycle:

  • clean
  • test
  • check
  • build
  • assemble

These tasks are wrapper tasks that declare a dependsOn to Grails specific tasks. This will allow for further build customization.

  • clean [grails-clean]
  • test [grails-test]
  • assemble [grails-war or grails-package-plugin]

You can also access any Grails command by prefixing it with grails-. For example, to run the application:

gradle grails-run-app

If you want to pass in some arguments, you can do so via the grailsArgs project property:

gradle -PgrailsArgs='--inplace solr' grails-create-plugin

You can also change the environment via the env project property:

gradle -PgrailsEnv=prod grails-run-app

You can execute multiple Grails commands in a single step, but bear in mind that if you are passing grailsEnv or grailsArgs then each of the commands will execute with the same values.

Troubleshooting

  • Caused by: org.apache.tools.ant.BuildException: java.lang.NoClassDefFoundError: org/apache/commons/cli/Options

    This happens if your project depends on the groovy JAR rather than groovy-all. Change your dependency to the latter and all will be well.

  • Classloading issues, casting proxy instances to their corresponding interface

    This can be a sign of a corrupted Spring-Loaded cache directory. The plugin has spring-loaded cache in $HOME/.grails/.slcache - try cleaning that directory

grails-gradle-plugin's People

Contributors

akiernan avatar cfieber avatar davidmc24 avatar graemerocher avatar htynkn avatar jeevatkm avatar johnlim avatar johnrengelman avatar ldaley avatar memorydoor avatar mrhaki avatar omerozkan avatar pledbrook avatar stokito avatar wpbeckwith avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.