or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

cli-interface.mdcollections-utilities.mdcore-runtime.mdindex.mdjson-processing.mdmeta-programming.mdscript-execution.mdsql-database.mdtemplate-processing.mdxml-processing.md
tile.json

tessl/maven-org-apache-groovy--groovy

Apache Groovy is a powerful, optionally typed and dynamic language, with static-typing and static compilation capabilities, for the Java platform aimed at improving developer productivity thanks to a concise, familiar and easy to learn syntax.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.apache.groovy/groovy@5.0.x

To install, run

npx @tessl/cli install tessl/maven-org-apache-groovy--groovy@5.0.0

index.mddocs/

Apache Groovy

Apache Groovy is a powerful, optionally typed and dynamic language, with static-typing and static compilation capabilities, for the Java platform aimed at improving developer productivity thanks to a concise, familiar and easy to learn syntax. It integrates smoothly with any Java program, and immediately delivers to your application powerful features, including scripting capabilities, Domain-Specific Language authoring, runtime and compile-time meta-programming and functional programming.

Package Information

  • Package Name: org.apache.groovy:groovy
  • Package Type: maven
  • Language: Groovy/Java
  • Installation: Add to Maven pom.xml: <groupId>org.apache.groovy</groupId><artifactId>groovy</artifactId><version>5.0.0</version>
  • Gradle: implementation 'org.apache.groovy:groovy:5.0.0'

Core Imports

import groovy.lang.*
import groovy.util.*

For Java interop:

import groovy.lang.GroovyShell;
import groovy.lang.Binding;
import groovy.lang.Script;

Basic Usage

// Simple script execution
def shell = new GroovyShell()
def result = shell.evaluate("2 + 2")
println result // 4

// Using closures
def multiply = { a, b -> a * b }
println multiply(3, 4) // 12

// Collections and ranges
def numbers = [1, 2, 3, 4, 5]
def evens = numbers.findAll { it % 2 == 0 }
println evens // [2, 4]

def range = 1..10
println range.collect { it * 2 } // [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]

Architecture

Apache Groovy is built around several key components:

  • Runtime System: Core language execution engine with dynamic method dispatch and meta-programming
  • Script Engine: Evaluation and compilation of Groovy scripts and expressions
  • Meta-Object Protocol: Comprehensive meta-programming capabilities through MetaClass system
  • Extension Modules: Modular APIs for JSON, XML, SQL, templates, CLI, and more
  • AST Transformations: Compile-time code generation and enhancement
  • Java Integration: Seamless interoperability with existing Java code and libraries

Capabilities

Core Language Runtime

Essential classes for the Groovy runtime including dynamic objects, closures, scripts, and the meta-programming system.

// Core interfaces and classes
interface GroovyObject {
    Object invokeMethod(String name, Object args)
    Object getProperty(String propertyName)
    void setProperty(String propertyName, Object newValue)
    MetaClass getMetaClass()
    void setMetaClass(MetaClass metaClass)
}

abstract class Script extends GroovyObjectSupport {
    abstract Object run()
    Binding getBinding()
    void setBinding(Binding binding)
}

abstract class Closure<V> extends GroovyObjectSupport {
    V call(Object... args)
    Closure<V> curry(Object... args)
    Closure<V> memoize()
}

Core Language Runtime

Script Execution and Evaluation

High-level APIs for evaluating Groovy code, managing bindings, and creating reusable scripts.

class GroovyShell {
    GroovyShell()
    GroovyShell(Binding binding)
    Object evaluate(String scriptText)
    Object evaluate(File file)
    Script parse(String scriptText)
    Class parseClass(String text)
}

class Binding {
    Object getVariable(String name)
    void setVariable(String name, Object value)
    Map getVariables()
}

Script Execution

Meta-Programming System

Comprehensive meta-programming capabilities for runtime method and property manipulation.

interface MetaClass {
    Object invokeMethod(Object object, String methodName, Object[] arguments)
    Object getProperty(Object object, String property)
    void setProperty(Object object, String property, Object newValue)
    List<MetaMethod> getMethods()
    List<MetaProperty> getProperties()
}

class ExpandoMetaClass extends MetaClassImpl {
    // Allows dynamic addition of methods and properties at runtime
}

Meta-Programming

Collections and Utilities

Enhanced collection operations, builder patterns, configuration management, and utility classes.

class Expando extends GroovyObjectSupport {
    // Dynamic object that allows adding properties and methods at runtime
}

abstract class BuilderSupport {
    protected abstract Object createNode(Object name)
    protected abstract Object createNode(Object name, Object value)
    protected abstract Object createNode(Object name, Map attributes)
}

class ConfigObject implements Map<String, Object> {
    // Configuration object supporting hierarchical properties
}

Collections and Utilities

JSON Processing

Complete JSON parsing and generation with builder patterns and streaming support.

class JsonSlurper {
    Object parseText(String text)
    Object parse(Reader reader)
    Object parse(File file)
}

class JsonBuilder {
    Object call(Closure closure)
    String toString()
    String toPrettyString()
}

class JsonOutput {
    static String toJson(Object object)
    static String prettyPrint(String jsonPayload)
}

JSON Processing

XML Processing

Comprehensive XML parsing, building, and manipulation with GPath expressions.

class XmlSlurper {
    Object parseText(String text)
    Object parse(File file)
    Object parse(Reader reader)
}

class MarkupBuilder extends BuilderSupport {
    // Builder for creating XML/HTML markup
}

class XmlParser {
    Node parseText(String text)
    Node parse(File file)
    Node parse(Reader reader)
}

XML Processing

SQL Database Access

Database operations with enhanced result sets and fluent query building.

class Sql {
    static Sql newInstance(String url, String user, String password, String driver)
    void eachRow(String sql, Closure closure)
    List<GroovyRowResult> rows(String sql)
    int executeUpdate(String sql)
    boolean execute(String sql)
    void call(String sql, Closure closure)
}

class DataSet {
    void each(Closure closure)
    DataSet findAll(Closure closure)
    void add(Map<String, Object> values)
}

SQL Database Access

Template Processing

Template engines for code generation and text processing.

class SimpleTemplateEngine {
    Template createTemplate(String text)
    Template createTemplate(Reader reader)
}

class StreamingTemplateEngine {
    Template createTemplate(String text)
    Template createTemplate(Reader reader)
}

Template Processing

Command-Line Interface

CLI building and option parsing utilities.

class CliBuilder {
    OptionAccessor parse(String[] args)
    void usage()
}

class OptionAccessor {
    // Accessor for parsed command-line options
}

Command-Line Interface

Types

// Core range types
interface Range<T extends Comparable> {
    boolean contains(Object o)
    T getFrom()
    T getTo()
    boolean isReverse()
}

class IntRange implements Range<Integer> {
    // Integer range implementation (e.g., 1..10)
}

// String interpolation
abstract class GString extends GroovyObjectSupport {
    String toString()
    Object[] getValues()
    String[] getStrings()
}

// Tuple types
class Tuple extends Object {
    // Base class for immutable tuples
}

// Utility types
class MapEntry<K, V> implements Map.Entry<K, V> {
    K getKey()
    V getValue()
    V setValue(V value)
}