UPDATE: Using the bootstrap configuration for the Tomcat plugin excludes it from the grails-war task.
See https://github.com/grails/grails-gradle-plugin/pull/43
Gradle support for Grails is maturing slowly and I must say that I can't wait for Grails 3.0. "Oh yeah, I'm excited!" :-), almost.
There are still few bits that I'm not clear about though in terms of how tight the integration will be, not specifically from an IDE usage perspective.
I watched a presentation from Luke Daley (aka alkemist) on Youtube(gr8conf 2013). It showcased the Gradle plugin for building Grails applications using the grails-gradle-plugin.
I was able to create a small POC and I want to share that experience with you.
General notes
Building a war and running Grails commands? Not a problem.gradle grails-run-app
gradle grails-war
You can configure the Grails environment using -PgrailsEnv as
-Dgrails.env=
Arguments can be specified using -PgrailsArgs
gradle -PgrailsArgs='com.Domain' grails-create-domain-class
For some reason, the grails-gradle-plugin seems to require a closure with a Grails version specified twice (assuming that version is only used for bootstrapping the initial call??, while grailsVersion is used for building). I think that it should probably be consolidated...
grails {
grailsVersion '2.2.3'
version '2.2.3'
}
Below is a build.gradle file that does work for the Grails Gradle plugin 2.0.0-SNAPSHOT. Dump the file into some folder and run gradle init first.
buildscript {
repositories {
mavenCentral()
maven { url 'http://repository.jboss.org/maven2/' }
maven { url 'http://repo.grails.org/grails/repo' }
maven { url 'http://repo.grails.org/grails/plugins' }
maven { url 'http://repository.springsource.com/maven/bundles/release' }
maven { url 'http://repository.springsource.com/maven/bundles/external' }
maven { url 'http://repository.springsource.com/maven/libraries/release' }
maven { url 'http://repository.springsource.com/maven/libraries/external' }
}
dependencies {
classpath 'org.grails:grails-gradle-plugin:2.0.0-SNAPSHOT',
'org.grails:grails-bootstrap:2.2.3'
}
}
version='0.0.1'
apply plugin: 'grails'
repositories {
mavenCentral()
maven { url 'http://repository.jboss.org/maven2/' }
maven { url 'http://repo.grails.org/grails/repo' }
maven { url 'http://repo.grails.org/grails/plugins' }
maven { url 'http://repository.springsource.com/maven/bundles/release' }
maven { url 'http://repository.springsource.com/maven/bundles/external' }
maven { url 'http://repository.springsource.com/maven/libraries/release' }
maven { url 'http://repository.springsource.com/maven/libraries/external' }
}
grails {
grailsVersion '2.2.3'
version '2.2.3'
}
configurations {
all {
exclude module: 'commons-logging'
exclude module: 'xml-apis'
}
test {
exclude module: 'groovy-all'
}
compile {
exclude module: 'hibernate'
}
}
dependencies {
compile( "org.grails:grails-crud:$grails.grailsVersion",
'org.grails:grails-gorm:1.3.7')
bootstrap "org.grails:grails-plugin-tomcat:$grails.grailsVersion"
}
No comments:
Post a Comment