I have been trying to configure Gradle to manage a Grails project for a couple of hours with no success. The suggestions I've found here on Stack Overflow and elsewhere on the Internet didn't work for me.
Could you please give me up-to-date directions on how to configure a Gradle+Grails project? Ideally it should relate to the current versions of Grails (2.1.0) and Gradle (1.1).
Grails 3.1 uses the Gradle Build System for build related tasks such as compilation, runnings tests and producing binary distributions of your project.
Gradle is a build management system which is open-sourced. The scripts are developed using Groovy or Kotlin DSL for managing builds. Grails is an opensource framework for developing full stack applications.
Running a Grails Application Using run-app Go to the application directory. For example, go to the as-install /grails/samples/helloworld directory. Run the grails run-app command. The grails run-app command starts the Enterprise Server in the background and runs the application in one step.
Grails is an open source web application framework which uses the Groovy programming language. It is intended to be a high-productivity framework by following the "coding by convention" paradigm, providing a stand-alone development environment and hiding much of the configuration detail from the developer.
import org.grails.gradle.plugin.GrailsTask
buildscript {
repositories {
mavenCentral()
mavenRepo name: "grails", url: 'http://repo.grails.org/grails/repo'
}
dependencies {
classpath "org.grails:grails-gradle-plugin:1.1.1-SNAPSHOT"
}
}
repositories {
mavenCentral()
mavenRepo name: "grails", url: 'http://repo.grails.org/grails/repo'
}
version = "1.0"
grailsVersion = "2.1.0"
apply plugin: "grails"
dependencies {
['dependencies', 'resources', 'core', 'hibernate', 'plugin-datasource', 'plugin-domain-class', 'plugin-tomcat', 'plugin-services'].each { plugin ->
compile "org.grails:grails-$plugin:2.1.0"
}
bootstrap "org.codehaus.groovy:groovy-all:1.8.6"
}
GRAILS_TASK_PREFIX = "grails-"
if (name.startsWith(GRAILS_TASK_PREFIX)) {
project.task(name, type: GrailsTask) {
command "${name - GRAILS_TASK_PREFIX}"
}
}
Then you can do gradle init
to initialize the project structure
Use gradle grails-[grails script]
to execute your grails commands. For example: gradle grails-run-app
is equivalent to grails run-app
Hope this helps!
This seems to work for Grails 2.3.2:
buildscript {
repositories {
mavenCentral()
maven { url 'http://repo.grails.org/grails/repo' }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:2.0.0-SNAPSHOT"
}
}
repositories {
mavenCentral()
maven { url 'http://repo.grails.org/grails/repo' }
}
version = "1.0"
apply plugin: "grails"
apply plugin: 'idea'
grails {
grailsVersion = "2.3.2"
}
dependencies {
['dependencies', 'core', 'spring', 'web', 'plugin-datasource', 'plugin-domain-class', 'plugin-controllers', 'plugin-services'].each { plugin ->
compile "org.grails:grails-$plugin:2.3.2"
}
compile 'org.grails.plugins:tomcat:7.0.42'
compile 'org.grails.plugins:hibernate:3.6.10.3'
compile 'com.h2database:h2:1.3.173'
bootstrap "org.codehaus.groovy:groovy-all:2.1.9"
}
A note, throws Exception when generating Grails wrapper, but gradle init
seems to initialize the project structure properly otherwise. And, gradle grails-run-app
seems to work fine too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With