2. Agenda
§ State of Nation
§ What’s planned for Grails 2.4?
§ What’s planned for Grails 3.0?
§ Summary / Q & A
3. State of Nation
§ Grails 2.4.3 most recent version
§ Grails 2.3.x line at 2.3.9
§ Hundreds of bugs fixed in the last 3
months
§ More than 1,100 plugins now for
Grails
10. Asset Pipeline Plugin
• Resources replaced with Asset
Pipeline
– https://github.com/bertramdev/asset-pipeline/
wiki/Why-asset-pipeline-over-grails-
resources-plugin
• Full documentation
– http://bertramdev.github.io/asset-pipeline/
• Many thanks to David Estes!
10
11. Standalone
• GORM for Hibernate 4 in Spring Boot
– https://spring.io/guides/gs/accessing-data-gorm/
• GORM for MongoDB in Spring Boot
– https://spring.io/guides/gs/accessing-data-gorm-mongodb/
• GSP standalone
– https://github.com/grails/grails-boot/tree/master/sample-apps/
gsp
11
12. @GrailsCompileStatic
• Grails-aware version of Groovy’s @CompileStatic
12
import
grails.compiler.*
!
@GrailsCompileStatic
class
BookController
{
…
}
13. Maven-style Dependency Management
• Use management block to declare managed dependencies
13
!
management
{
dependency
"commons-‐logging:commons-‐
logging:1.1.3"
}
14. Hibernate Subqueries
• Perform nested “in” or “notIn” sub queries that span domain
classes using where queries:
14
def
employees
=
Employee.where
{
region.continent
in
['APAC',
"EMEA"]
}.id()
!
def
results
=
Sale.where
{
employee
in
employees
&&
total
>
50000
}.employee.list()
16. Hibernate Column Readers/Writers
• Implement custom column readers and writers to transform
data when written or read from the database.
16
Name
{
String
title
static
class
mapping
=
{
title
write:'UPPER(?)',
read:'REPEAT(title,
2)'
}
}
17. Hibernate 4 in Unit Tests (Coming Soon)
• Test Hibernate 4 interaction in unit tests
17
import
grails.test.mixin.hibernate.*
!
@TestMixin(HibernateTestMixin)
class
PersonSpec
extends
Specification{
void
setupSpec()
{
hibernateDomain([Person])
}
…
}
18. GORM for MongoDB 3.0
• Support for MongoDB 2.6
• GeoJSON type support
• Maps of entities
• Full Text Search
• Projections using Aggregations
• Size queries (sizeEq, sizeLt etc.)
• Spring Boot
– https://spring.io/guides/gs/accessing-data-
gorm-mongodb/
18
19. New Maven Plugin 2.4.3
• Upgraded to Maven 3.1+
• Rewritten to use Aether for dependency resolution as per
recommendations
• Can now be used with multiple versions of Grails:
19
<configuration>
<grailsVersion>2.3.8</grailsVersion>
</configuration>
20. Grails 2.4.x TODOs
• Grails 2.4.4 - Out Soon
• Spring Security Core 2.0 GA
• Spring Web Flow Plugin Update
• Bug Fixes
20
2.4
23. Grails 3.0: Goals
• Embrace Gradle
• Abstract Packaging / Deployment
• Reach outside the Servlet Container
• App Profiles: Netty, Servlet, Batch,
Hadoop
• Deployment with run-app / runnable
JARs
• Extend the reach of Grails
23
33..00
24. Grails 3.0: Goals
• Build on Spring Boot
• Plugin System & Events
• Support Multi Project Builds
• Support Micro Services
• Remove Bloat
• Reduce Dependencies
24
33..00
25. Spring IO Platform Reprise
25
XD GRAILS
Bootable, Minimal, Ops-Ready
INTEGRATION BATCH BIG DATA WEB
Jobs, Steps, Ingestion, Channels, Adapters, Export, Controllers, REST,
SPRING CORE
FRAMEWOR SECURIT GROOV REACTO
DATA
RELATIONA NON-BOOT
IO
IO
26. Spring IO Platform
26
Grails
Spring IO Platform
Spring XD
Spring Foundation
Apps
Spring Boot
3rd Party Dependencies
27. Spring IO & Grails
• What does Spring IO bring to Grails?
– Standardised dependency management
– Published BOMs for use with Maven & Gradle
– Foundational libraries
– See more http://docs.spring.io/platform/docs/current/
reference/htmlsingle/
27
dependencies
{
compile
'commons-‐lang:commons-‐lang'
}
28. Gradle
• Deprecate existing build system
• Replace with Gradle build
• Easier now everything is forked in 2.3.x
• All the flexibility of a powerful build
system
• Separate build plugins can provide
Gradle extensions
28
32. Spring Boot
• Grails 3.0 to be built on Spring Boot
• Boot to handle
• Embedded servers
• Runnable JARs
• WAR packaging
• Scripting / Micro Services
32
33. Why Spring Boot?
• Handles Fat JAR and embedding
• Already supports different runtimes
• Includes monitoring and health
checks
• Grails can take advantage of Boot
auto configuration
33
34. Boot Powered Micro Services
34
@Grab("com.h2database:h2:1.3.173")
import
grails.persistence.*
!
@Entity
@Resource(uri='/books')
class
Book
{
String
title
}
36. Deprecations / Removals
• Servlet 2.5 support (no web.xml)
• Gant & Current Build System
• GDoc - Replaced by AsciiDoctor
• Integration Tests - Replaced by more
Mixins
• Converters / Codecs plugins -
Replaced by Groovy extensions
• Filters - Replaced by new mechanism
36
37. Servlet 3.0 only and no web.xml
• Thanks to Spring Boot, new servlets and filters can just be
Spring beans
37
!
def
doWithSpring
=
{
characterEncodingFilter(
CharacterEncodingFilter)
{
encoding
='utf-‐8'
}
}
40. Grails 3.0 Flow
• GrailsDispatcherSerlvet 50 lines of code in 3.x,
but 545 lines in 2.x
40
DispatcherServlet
GrailsController
Delegate Request
41. Benefits of Simplification
• Less code to maintain
• Better performance
• Better integration with Spring
• Fewer dependencies
• commons-fileupload gone
• No internal forwarding
41
43. Grails 3.0 & Groovy Traits
• Most logic previously added via AST transforms will now be
added by Traits
– (Cases not possible as Trait done with transforms)
43
trait
Controller
{
…
def
withFormat(Closure
callable)
{
…
}
}
44. Application Profiles
• Each profile will have distinct plugins, runtimes and
packaging (JAR, WAR etc.)
44
!
$
grails
create-‐app
myapp
-‐-‐profile=netty
$
cd
myapp
$
grails
package
$
java
-‐jar
target/myapp.jar
!
45. Application Profiles
• Extensible profiles with an API exposing structure
• Profile specific commands (run, package, test)
• Profile specific plugins
• Profile specific project templates and file templates (code
generators) backed by Git
• Community maintained profiles and core profiles
45
46. Profile Repository
• All Profiles managed by git
• Profiles checked out locally and periodically updated
• Profiles wrap code generation infrastructure
46
$
grails
create-‐controller
foo
!
Profile
.getCurrentProfile()
.getCommand('create-‐controller')
.execute(
'foo'
)