100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Programming

Apache Groovy

By the Apache Software Foundation

IntermediateLanguage3.9K learners

Apache Groovy is a dynamic, optionally-typed programming language for the Java Virtual Machine (JVM) that offers concise syntax, closures, and full interoperability with existing Java code and libraries.

Definition

Apache Groovy is a dynamic, optionally-typed programming language for the Java Virtual Machine (JVM) that offers concise syntax, closures, and full interoperability with existing Java code and libraries.

Overview

Groovy was created by James Strachan in 2003 as a more expressive, scripting-friendly companion to Java, and later became a project of the Apache Software Foundation, graduating to top-level status in 2015. It compiles to JVM bytecode, so Groovy code can call Java libraries directly and vice versa, making it easy to adopt incrementally inside existing Java codebases. By default Groovy is dynamically typed, but developers can opt into static type checking and compilation with the @TypeChecked and @CompileStatic annotations when performance or stricter guarantees are needed. The language adds concise native syntax for lists, maps, ranges, and regular expressions, along with first-class closures, which make it well suited to scripting and building internal domain-specific languages (DSLs). Groovy's biggest real-world footprint today is arguably as the scripting language behind two widely used build and automation tools: Gradle build scripts and Jenkins pipeline definitions (Jenkinsfiles) are both written in Groovy DSLs. It is also the foundation of the Grails web framework and is commonly paired with the Spock testing framework for expressive, readable JVM test suites.

Key Features

  • Seamless interoperability with Java libraries and code
  • Optional static typing via @TypeChecked and @CompileStatic
  • First-class closures and functional-style programming support
  • Concise native syntax for lists, maps, ranges, and regular expressions
  • Groovy Development Kit (GDK) extending Java's standard library
  • Powers Gradle build scripts and Jenkins pipeline DSLs
  • Dynamic metaprogramming via categories and metaclasses

Use Cases

Writing Gradle build scripts for JVM projects
Authoring Jenkins pipeline (Jenkinsfile) automation
Rapid scripting and automation tasks on the JVM
Building web applications with the Grails framework
Writing expressive unit tests with the Spock framework
Creating internal domain-specific languages (DSLs)

Frequently Asked Questions