Apache Groovy 2.5 arrived: Major improvements and a bright future
The veteran of the JVM languages is here with a brand new release stuffed with groundbreaking enhancements and a promising roadmap! Here, we have a look at the highlights of the latest release and we go over some remaining issues.
The 15-year-old language for the JVM, Groovy, is here with a new release packed with improvements and a whole lot more coming up on its roadmap.
The absolute highlight of the new release is the support for macros that let you use Groovy syntax directly rather than using the internal compiler representations when creating compile-time metaprogramming extensions.
But that’s not all. Let’s check out the new features and enhancements.
groovyConsolenow run JUnit 5 tests directly
- The Groovy CLIBuilder tool, that helps to process command-line arguments, now supports annotation style definitions. Also, revamped versions of CLIBuilder now support Commons CLI and Picocli-backed parser implementations
- Repeated annotation
- Various JSON customizations
- Names for method parameters now are accessible at runtime, a capability also supported in JDK 8
- For AST transformations,
@Canonicalis now a meta-annotation, allowing for more flexible usage of annotation attributes from constituent annotations. Developers can also define a custom meta-annotation
@Canonicalexpands into the
@ToStringannotations, with annotation, attributes distributed to component annotations that support them
In order to build with Groovy, JDK 8 or a later version is required. JDK 7 is the minimum version of JRE supported by Groovy 2.5.
What is more, there is an extensive list of fixed issues that, according to the official release notes, may also be considered breaking changes in some situations. Take a look at the list here.
Nonetheless, there are some issues that still remain:
- The GDK documentation for the java.time extensions wasn’t included in the release. It will be included in the first maintenance release (2.5.1) but, in the meantime, can be found here.
- Users of
groovy.util.CliBuilderneed to also include the
org.codehaus.groovy:groovy-cli-commonsdependency on their compile classpath in addition to
groovy-all. This won’t be required after the next maintenance release but users should migrate away from that class in any case as it will be removed from the next major version of Groovy.
- Users of Spock 1.1-groovy-2.4 may find strange ClassCastException errors with some tests. You can have a look at this GitHub repo for some help.
- Users combining
finaland Spock may see errors from the final variable analyzer. You may need to temporarily remove the
finalmodifier in the meantime.
- Users needing the groovy-xml module and running on JDK9 and above may need to use the
--add-modules java.xml.bindcommand-line option to fix the break in backwards compatibility caused by JDK9+.
- JDK9+ produces warnings with many libraries including Groovy due to some planned future restrictions in the JDK but work is underway to re-engineer parts of Groovy to reduce/remove those warnings. Users wanting to hush the warnings as an interim measure may consider using the
--add-opensescape clause offered by JDK9+. See commit
92bd96f(currently reverted) on the Groovy master branch for a potential list to add.
There’s still more to come
Although Groovy 2.5 is stuffed with enhancements and fixed issues, we are not done yet. The 2.6 and 3.0 releases are expected within the next year and they aim users of Java 7 and Java 8 and 9 respectively. Take a look at the full Groovy roadmap here.