Grails - Building with Gradle



Description

The gradle is used for performing some tasks such as compilation, running tests etc on your application. You can get the version of the project, dependencies of the project, and repositories for finding dependencies in the build.gradle file.

 
buildscript {
    repositories {
        mavenLocal()
        maven { url "https://repo.grails.org/grails/core" }
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
        classpath "org.grails.plugins:hibernate5:${gormVersion-".RELEASE"}"
        classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.14.2"
    }
}

version "0.1"

Dependencies with Gradle

You can find the dependencies of the project in the dependencies section of the build.gradle file as shown below:

 
dependencies {
    compile "org.springframework.boot:spring-boot-starter-logging"
    compile "org.springframework.boot:spring-boot-autoconfigure"
    compile "org.grails:grails-core"
    compile "org.springframework.boot:spring-boot-starter-tomcat"
    compile "org.grails:grails-logging"
    compile "org.hibernate:hibernate-core:5.1.5.Final"
    compile "org.grails.plugins:gsp"
    console "org.grails:grails-console"
	
    profile "org.grails.profiles:web"
	
    runtime "org.apache.tomcat:tomcat-jdbc"
    runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.14.2"
	
    testCompile "org.grails:grails-plugin-testing"
    testCompile "org.grails.plugins:geb"
	
    testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
    testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
}

Working with Gradle Tasks

The below table provides list of Grails command for performing Gradle task:

S.N.Grails CommandGradle Task
1 clean clean
2 compile classes
3 package assemble
4 run-app bootRun
5 test-app test
6 test-app --integration integrationTest
7 war assemble

You can find the set of Gradle plugins in the build.gradle file for building the Grails project:

 
apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"asset-pipeline"
apply plugin:"org.grails.grails-gsp"

In the above plugins, you will be having war and asset-pipeline plugins as default. The war plugin provides War file from the project and asset-pipeline plugin enables the static assets of the project.

There are many other plugins specified by the Gradle or third party plugins as listed below:

S.N.Grails Plugins
1 org.grails.grails-core
It is a primary Grails plugin used for operating with all profiles.
2 org.grails.grails-gsp
It provides the adds precompilation of GSP files for production deployments.
3 org.grails.grails-doc
It is used for Grails 2.0's documentation engine.
4 org.grails.grails-plugin
It builds the Grails plugins for Gradle.
5 org.grails.grails-plugin-publish
It publishes the Grails plugins in the central repository.
6 org.grails.grails-profile
It is used for creating Grails profiles.
7 org.grails.grails-profile-publish
It publishes the Grails profiles in the central repository.
8 org.grails.grails-web
It is a web gradle plugin used for configuring Grails conventions and directory structure.
Advertisements