An example project showing how you can migrate from Java to Groovy for fun and profit!
Java
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src/main/java/us/juggl/twentysixteen/september/java
.gitignore
README.md
pom.xml

README.md

How to switch a project from Java To Groovy

For fun and profit!

Overview

This presentation for the Java Users Group of Greater Louisville shows the path and potential benefits of switching from writing Java code to writing code for the JVM in Groovy. The slides and notes to accompany this presentation can be found HERE.

Build And Run The Project

mvn clean compile exec:java

Description

  • Start with the branch: Step-00, this is a simple Java project using Vert.x.
    • Study the project and make sure you understand what is going on with the lambdas and method references
  • Switch to the Step-01 branch to see that we have now added a new class, but this one is written in Groovy and can work alongside the Java classes!
    • The Maven pom.xml file is set up to be able to compile Groovy source files along with Java source files
    • Look at the comments in the Groovy code to see some interesting syntactic sugar available with Groovy
  • Switch to Step-02 and see that we have converted the original Java source file to Groovy
    • Take note of the syntax differences:
      • Map literals
      • Different method references (Closures actually!)
      • Differences between List syntax in Java and Groovy
  • Switch to Step-03 for a view of some more advanced features of Groovy:
  • Step-04: Bonus! Using Groovy for CLI scripts