Groovy is also a scripting language, you can easily… ! – run a Groovy script with the groovy command ! – @Grab & import third-party libraries •no need for a dedicated project or a build file •leverage the wealth of Ant tasks with the Groovy Ant builder ! – invoke other command-line tools !20
anybody :-) Or me for grepping through the logs to compute download stats Anyone who’s not a Bash guru! Groovy team exports Confluence wiki to html, then transforms to AsciiDoc format
feature – an Ant task scripting API to reuse all existing Ant tasks •ftp, ssh, file copying/moving… – a template engine •for generating files, source code – easy creation & parsing of XML or JSON payloads – Sql facility to simplifying accessing a JDBC compliant relational DB – exposing and accessing JMX beans !26
Gradle is a powerful build automation solution – uses Groovy for its automation language ! • You can – build / package / deploy Java, Groovy, Scala, C/C++ projects – handle dependency management cleanly – define and enforce your own enterprise build conventions – extend Gradle declaratively and programmatically !30
Groovy-based initiatives around the DevOps theme ! • Goals – handle Amazon AWS configuration, provisioning and deployments – talking with remote servers through SSH, and automating server configuration, working with scp and more !36
! – http://slideshare.net/aestasit/groovy-dev-ops-in-the-cloud – sshoogr: a Groovy-based DSL for working with remote SSH servers – grammazon: a Groovy library and Gradle plugin for working with Amazon EC2 instances ! – https://github.com/danveloper/provisioning-gradle-plugin – a Gradle plugin for driving server provisioning through configuration !37
! • Many companies started integrating Groovy in their projects through testing, before any line of Groovy code in production ! • Benefit – easier to add, evolve and maintain test cases !50
An HtmlUnit, FireFox or Chrome browser Drive the browser to a certain URL Assert the title contains the text Fill in a form, click the button to send it
• You need to… ! – customize an application for a particular customer – configure an application for a particular environment – create / update / externalize business rules – create plugins for extending a platform !60
Jenkins provides two Groovy plugins: ! – the Groovy plugin https://wiki.jenkins-ci.org/display/JENKINS/Groovy+plugin •execute arbitrary Groovy scripts as Jenkins jobs ! – the Groovy postbuild plugin https://wiki.jenkins-ci.org/display/JENKINS/Groovy+Postbuild+Plugin •set build outcome, display badges, info or error messages, once a build completed !62
Home automation in the era of the Internet of Things ! • Built-in IDE and simulator allow you to automate all your devices of your home with Groovy scripts https://support.smartthings.com/entries/21603015-Introduction-to-Writing-SmartApps ! • Groovy supports allows to • set preferences, subscribe to events, set timers, handle events, send notifications, access people’s presence, consume external services… !64
Home automation in the era of the Internet of Things ! • Built-in IDE and simulator allow you to automate all your devices of your home with Groovy scripts https://support.smartthings.com/entries/21603015-Introduction-to-Writing-SmartApps ! • Groovy supports allows to • set preferences, subscribe to events, set timers, handle events, send notifications, access people’s presence, consume external services… !64
XWiki is a second-generation wiki http://www.xwiki.org/ (XWiki case study: http://bit.ly/xwiki-cs) • not just content, but programmable • a platform for building your own apps • extensible with plugins and macros ! • You can create your own plugins and macros in Groovy to extend the wiki, and add dynamic content !66
Groovy also brings to the table: ! • a rich API for integrating and embedding Groovy in your app • GroovyShell, Binding, customizers… ! • dedicated configuration API (ConfigSlurper) with a special « builder » syntax with a hierarchical data structure ! • a JMX bean & JMX builder for interacting with and exposing JMX services !68
The goal of Groovy Domain-Specific Languages: • beyond just integrating Groovy scripts and classes: create a dedicated mini-language modeling your business • less technical boilerplate code, focus on the business semantics • write almost plain English-like sentences ! • Groovy has… • a succint, flexible & malleable syntax • both dynamic and compile-time metaprogramming capabilities • operator overloading !70
Fortune 500 insurance actuaries write risk calculation rules in Groovy EPO built a data flow language atop Groovy to extract / transform / route patents across patent offices
Fortune 500 insurance actuaries write risk calculation rules in Groovy EPO built a data flow language atop Groovy to extract / transform / route patents across patent offices 1 billion € worth of loan granted through Hypoport’s financial platform Groovy decision rules
Fortune 500 insurance actuaries write risk calculation rules in Groovy EPO built a data flow language atop Groovy to extract / transform / route patents across patent offices 1 billion € worth of loan granted through Hypoport’s financial platform Groovy decision rules Customize experience of travel and hotel reservation with Groovy scripts and templates
Fortune 500 insurance actuaries write risk calculation rules in Groovy EPO built a data flow language atop Groovy to extract / transform / route patents across patent offices 1 billion € worth of loan granted through Hypoport’s financial platform Groovy decision rules Customize experience of travel and hotel reservation with Groovy scripts and templates Case study: http://bit.ly/epo-cs
uses BigDecimal by default for floating point • you can, of course, specify floats or doubles if needed • important for financial calculations w/ exact arithmetics !72
uses BigDecimal by default for floating point • you can, of course, specify floats or doubles if needed • important for financial calculations w/ exact arithmetics !72
uses BigDecimal by default for floating point • you can, of course, specify floats or doubles if needed • important for financial calculations w/ exact arithmetics !72
uses BigDecimal by default for floating point • you can, of course, specify floats or doubles if needed • important for financial calculations w/ exact arithmetics !72 Which formula would you rather maintain?
uses BigDecimal by default for floating point • you can, of course, specify floats or doubles if needed • important for financial calculations w/ exact arithmetics !72 Which formula would you rather maintain? Operator overloading
rich of tools, frameworks, and libraries ! • For web development, you can use – the mainstream Grails web stack, powered by Spring and Groovy – the newcomer Ratpack, a lightweight toolkit on top of Netty – or Spring Boot, an opinionated & Groovy-friendly take on Spring ! • For desktop applications, you can use Griffon – which supports different view toolkits such as GroovyFX, Swing, Pivot… !77
web framework ! • Grails is a full web stack for the JVM – based on Groovy and Spring – can interact with relational databases through Hibernate or through any NoSQL datastore with Spring Data, with the GORM mapping layer – follows the Convention over Configuration paradigm – lets you see changes live with hot reloading – advanced REST and Async support – built-in view technology (GSPs) with taglibs !78
framework !79 Created the Open Source Asgard web interface for application deployments and cloud management in Amazon Web Services LinkedIn uses Grails for their commercial portals, for recruiters, companies searching for profiles…
framework !79 Created the Open Source Asgard web interface for application deployments and cloud management in Amazon Web Services LinkedIn uses Grails for their commercial portals, for recruiters, companies searching for profiles… Many web frontends from the Sky network serving a few hundred millions page views a month
framework !79 Created the Open Source Asgard web interface for application deployments and cloud management in Amazon Web Services LinkedIn uses Grails for their commercial portals, for recruiters, companies searching for profiles… Many web frontends from the Sky network serving a few hundred millions page views a month Wired’s product review section is powered by Grails
language... ! • But... – as type safe as you want it — static type checking – as fast as you need it — static compilation – as functional as you make it — closures... !83
automation, DevOps • Extension points for customizing / configuring apps • More readable and expressive tests • Business languages & Domain-Specific Languages • Full blown apps – for the web with Grails, Ratpack, Gaelyk – for web reactive programming with Reactor – for desktop with Griffon !84