Better know a Grails Plugin



Welcome

Who am I?

Eric Helgeson

erichelgeson@gmail.com

@nulleric

Grails Consulting at Agile Orbit

http://www.agileorbit.com

Sproutary.com

Online software for Pre-Schools and Day Cares.
https://sproutary.com

Practical Grails 3


https://www.grails3book.com

Join Groovy/Grails Slack

What is this talk about?

Survey - Show hands

Version of Grails?

3?
2?
1…?

A journey around the Grails 3 ecosystem

See many plugins you know and some you don’t with example code

Plugins are what makes Grails great

So many good plugins out there allow you to quickly setup sane defaults for your app and get going quickly

Plugins are why we use Grails

Little less magic and a lot more standard

Venture outside the Grails ecosystem

Brief history of Grails 3 plugins

Grails 3 changed (for the better) how plugins work

Jars

Build system is now gradle

Grails is now built on top of Spring Boot

Early Days

Today

But new issues

Scheduling

@Scheduled

SpringBoot already comes with one

Great for simple scheduling

Demo!

scheduling/scheduled

Quartz Plugin

Quartz Plugin

Few rough edges

Demo!

scheduling/quartz

Schwartz

Also built on Quartz

Different approach

Demo!

scheduling/schwartz

Quartz Pro Tips

Jesque

Similar to Ruby resque

quartz-admin & jesque-admin

Security

Spring Security

spring-security-core

s2-quickstart

$ grails s2-quickstart com.yourapp User Role

CONFIGURE SUCCESSFUL in 7s
| Creating User class 'User' and Role class 'Role' in package 'com.yourapp'
| Rendered template PersonWithoutInjection.groovy.template to destination grails-app/domain/com/yourapp/User.groovy
| Rendered template PersonPasswordEncoderListener.groovy.template to destination src/main/groovy/com/yourapp/UserPasswordEncoderListener.groovy
| Rendered template Authority.groovy.template to destination grails-app/domain/com/yourapp/Role.groovy
| Rendered template PersonAuthority.groovy.template to destination grails-app/domain/com/yourapp/UserRole.groovy
| 
************************************************************
* Created security-related domain classes. Your            *
* grails-app/conf/application.groovy has been updated with *
* the class names of the configured domain classes;        *
* please verify that the values are correct.               *
************************************************************

Recent improvements

Extras

spring-security-rest

spring-security-ui

Others

Demo!

security/spring-security

Honorable Mentions

Session Management

Spring-Session

Plugin or not?

Demo!

session/springsession

Database

Database Migration

Generates DB Schema

FlyWay

Demo!

db/dbm
db/flyway

DB Logging

we all know sqlLogging= true, helpfull, but not always clear.

p6spy sits between your app and jdbc driver and intercepts & logs exact sql queries (with params!) unlike hibernate sqlLogging

hibernateStats is available, easily added to an dev-time interceptor

Good to have on in development to quickly see if you’re making 1 or 1000 sql queries, or flushing the session 100’s of times.

Demo!

db/logging

dialects

Demo!

db/dialects

MultiTenant

Great Guides

Demo!

db/multitenant

Honorable mentions

Email

grails-mail

spring-boot-starter-mail

spring-boot-email-tools

API email services

Email Testing

Demo!

mail/emailtools

Front End

Asset Pipeline

Client Dependencies (gradle)

node npm gradle plugin

Demo!

sproutary-grails

Demo!

frontend/assets

HTTP Clients

Consider newer libs

Servlet Containers

https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/html/howto-embedded-web-servers.html

Demo!

container/undertow
container/tc

Also

https://www.grails3book.com/blog/2018/2018-03-27-tomcat-native.html

Configuration

external-config

https://plugins.grails.org/plugin/grails/external-config

Spring Boot Externalized Conf

Spring Boot Starters

https://github.com/spring-projects/spring-boot/tree/1.5.x/spring-boot-starters

Spring Boot Endpoints

https://docs.spring.io/spring-boot/docs/1.5.x/reference/html/production-ready-endpoints.html

Demo!

info/info

Profiles

list-profiles

➜  source grails list-profiles
| Available Profiles
--------------------
* angular - A profile for creating Grails applications with Angular 2
* rest-api - Profile for REST API applications
* base - The base profile extended by other profiles
* angularjs - A profile for creating applications using AngularJS
* plugin - Profile for plugins designed to work across all profiles
* profile - A profile for creating new Grails profiles
* react - A profile for creating Grails applications with a React frontend
* rest-api-plugin - Profile for REST API plugins
* web - Profile for Web applications
* web-jboss7 - A Profile for Creating a JBoss 7.1 EAP Project
* web-plugin - Profile for Plugins designed for Web applications
* webpack - A profile for creating applications with node-based frontends using webpack

Testing

Grails Testing

New Trait based framework (3.3+)

Older Mixin framework still works in 3.3+

Test Data

CodeNarc

Coverage

More info
http://mariogarcia.github.io/blog/blog/2017/04/grails_coverage.html

Demo

testing/testing

Sometimes a plugin is overkill.

Sometimes unnecessary even for a plugin

Using the tools you have, build your own!

Grails provides a lot of great tools to build the functionality you ended quickly

Settings plugin (older 2.x plugin)

Evaluating Plugins

What to look for:

Where’d they go?

Conclusion

The Current Echosystem

good

Everything you need to build a website quickly is there.

bad

Discover-ability
You need to know where to look, or come to this talk to find everything.

ugly

years between releases
better changelogs
broken links

Thanks

Deployment

My preferred way AWS elastic beanstalk

AWS gradle plugins make this trivial

What to know

Docker

docker gradle plugins

Easily build your jar into a container, and define your other infra containers as well

sshoogar

Sometimes you just need to push a file somewhere and restart a service

sshoogar - dsl for doing just that

War (gradle deploy plugin)

https://github.com/bmuschko/gradle-cargo-plugin

Deploy war to Tomcat api

Deploy info

(git commit,)

grailsinfocontributor

Logging slf4j
remote api

Log Accutator API, change logging on the fly

Ship logs off system!
Splunk, ELK, Papertrail, anywhere!

Views

GSP (Yes it’s a plugin now)

Gson (json views)

Static type, speed, inheritance, etc

hal

json-api

Markup

grails-vaadin-plugin

Documentation

asciidoctorj

Easy & powerful writing tool
Gradle integration

Keep documentation with your code!

Publish to static site (s3/etc)

spring-restdocs

https://github.com/jlstrater/grails-spring-restdocs-example

swagger

https://github.com/ajay-kmr/swagger

Or just use the library itself

Metrics

http://plugins.grails.org/plugin/grails/dropwizard-metrics

http://plugins.grails.org/plugin/sergiomichels/grails-melody-plugin

statsd metrics

Sentry

Datadog

Accutaotrs monitoring

Health

Build your own

(careful, up/down one) - https://tedvinke.wordpress.com/2017/10/25/why-is-springs-health-down-down-up-up-up-and-down-again/

Web (Other)

Cookie

scaffolding

Not really something I use, anyways right after building

scaffolding

angular-scaffolding