Groovy

Groovy: Start where the language runs, what it shares with Java, and why Gradle and Spock are written in it Open Groovy: The language basics dynamic variables, declared types, and when each one is the right choice Open Groovy: Control flow conditions, the Elvis default and the block that returns a value Open Groovy: Collections the literal, indexing, negative indexes, adding and removing, and the list a method returns Open Groovy: Closures the braces, the implicit it, typed parameters and the value a closure returns Open Groovy: Object orientation the property Groovy generates, the field behind it, and the accessors Open Groovy: Metaprogramming and DSLs a class that answers a call it does not declare, and the error it throws for a typo Open Groovy: Data, files and processes write, read, append, walk a folder, and the File methods the GDK adds Open Groovy: Tests and builds given, when, then and expect, run by the JUnit Platform Open

All articles

About the course

Groovy is a language for the Java platform: it compiles to the same bytecode as Java, uses the Java libraries without a wrapper, and drops the ceremony a script does not need. The course below is a chain of lessons. Each one takes one idea, shows whole scripts with their real output, and names the lesson before it and the lesson after it.

Every script was run in this container with Groovy 5.0.8 on OpenJDK 21.0.13, and every output block is copied from that run. The lint checks use CodeNarc 4.0.0 with the ruleset of this site, so the code the lessons show is also the code the linter accepts. There is no network: a lesson that would need a repository or a server shows the failure it gets instead of pretending it works.

Gradle build scripts are Groovy, and the Groovy DSL lesson of that course reads one line by line. The Groovy errors page collects the messages a beginner meets with their causes, and the older Groovy overview is kept as it was.

Related