(Quick Reference)

1.2 What's new in Grails 3.1?

Version: 3.2.6

1.2 What's new in Grails 3.1?

Grails 3.1 includes the following new features.

Spring Boot 1.3 and Spring 4.2

Grails 3.1 has been upgraded to Spring Boot 1.3 and Spring 4.2.

1.2.1 Improvements to Grails 3 Profiles

Profile Publishing and Repositories

The following improvements are available in Grails profiles:

  • Profiles are now published as regular JAR files to any Maven compatible repository (Artifactory, Nexus etc.).

  • Additional profiles can be created easily with the new create-profile command.

  • Profiles can now contribute to the generation of the build

  • Profiles can now have one or many features

For more information see the new section on Profiles in the user guide.

1.2.2 REST API and AngularJS Profiles

REST Profile

A new profile is available designed for the creation of pure REST applications without a UI.

To create a REST application use the rest-api profile as an argument to create-app:

$ grails create-app myapp --profile=rest-api
In earlier milestones this profile was named web-api. The profile has been renamed rest-api which more appropriately describes its purpose.

Then start interactive mode to see the available commands for the profile:

$ cd myapp
$ grails

If you hit TAB you will notice code generation commands specific to the profile including:

  • create-domain-resource - Creates a domain class annotated with the Resource annotation)

  • create-restful-controller - Creates a controller that extends RestfulController.

JSON and Markup Views

The REST profile includes the ability to define JSON and Markup views and the build.gradle features the ability to compile these views for production use.

The REST profile also creates JSON views to render the index action and common commands such as generate-views have been overridden to generate JSON views.

AngularJS Profile

An initial version of the AngularJS profile is now available, making it easier to create and integrate AngularJS with Grails 3 applications.

To create a Grails 3 AngularJS application use the angular profile as an argument to create-app:

$ grails create-app myapp --profile=angular

Then start interactive mode to see the available commands for the profile:

$ cd myapp
$ grails

You will notice new commands such as create-ng-component, create-ng-controller etc. that help you get going creating an AngularJS application.

The build.gradle is also preconfigured with the necessary Gradle plugins to integrate AngularJS with Asset Pipeline. The created Angular application can be found in grails-app/assets/javascripts.

For more detail on what the Angular profile provides, see the AngularJS Profile section in the documentation

1.2.3 GORM 5 Suite

Grails 3.1 ships with GORM 5 which is a brand new release of GORM supporting the following technologies:

  • Hibernate 3, 4 and 5 - for SQL databases GORM for Hibernate now supports the latest Hibernate 5.x release

  • MongoDB 3.x - GORM for MongoDB has been upgraded to the MongoDB 3.x Java driver and supports codec based persistence

  • Neo4j 2.3.x - GORM for Neo4j has been significantly improved and support the latest release of Neo4j

  • Cassandra - GORM for Cassandra supports the latest 2.0.x drivers

For more information refer to the new GORM 5 website.

1.2.4 Grails Wrapper

The Grails wrapper is back starting with Grails 3.1.14!

You can use it the same way you use any Grails command inside a project.

./grailsw create-controller foo

1.2.5 Plugin Publishing Plugins

New Gradle plugins are available to simplify publishing of plugins and profiles.

To utilize the plugin apply the org.grails.grails-plugin-publish plugin (after any existing Grails plugins for Gradle):

apply plugin: "org.grails.grails-plugin"
apply plugin: "org.grails.grails-plugin-publish"

For a profile the grails-profile-publish plugin can be used instead:

apply plugin: "org.grails.grails-profile"
apply plugin: "org.grails.grails-profile-publish"

Then configure the plugin. For example:

grailsPublish {
    user = 'user'
    key = 'key'
    githubSlug = 'foo/bar'
    license {
        name = 'Apache-2.0'
    }
    title = "My Plugin Title"
    desc = "My Plugin Description"
    developers = [johndoe:"John Doe"]
}

The user and key are your Bintray credentials. With this done you can continue to use bintrayUpload to publish your plugin. In addition, if you wish to update the Grails plugin portal, you simply need to configure your grails.org credentials:

grailsPublish {
    ...
    portalUser = "..."
    portalPassword = "..."
}

Then call notifyPluginPortal to update the Grails.org Plugins website:

gradle notifyPluginPortal