Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Documented pre-compiled extensions


Is it possible to use compiled scripts?

At the moment, no. The way the DSL is currently implemented disallows it.

It is possible starting from Groovy 2.2.0. Using a precompiled type checking extension requires a fully qualified class name instead of a resource path:

Code Block
void methodTypeCheckedWithExtension() { ... }

Compiling the extension can be done using groovyc and a regular type checking extension script:

No Format
groovyc -b MyExtension.groovy

However, in general you will want to compile the extension as part of a larger project. In that case, you can write an extension by extending the GroovyTypeCheckingExtensionSupport.TypeCheckingDSL class:

Code Block


class PrecompiledExtension extends GroovyTypeCheckingExtensionSupport.TypeCheckingDSL {

    Object run() {
        // body of the script
        setup {
            addStaticTypeError('Error thrown from extension', context.enclosingClassNode)
			methodNotFound { receiver, name, argList, argTypes, call ->
				// ...

Note how the actual extension code needs to be wrapped into the run method.

Can I use @Grab in a type checking extension?