@Documented @Retention(value=SOURCE) @Target(value=LOCAL_VARIABLE) public @interface BaseScript
The type of the variable annotated with must extend Script.
It will be used as the base script class.
The annotated variable will become shortcut to this object.
Using this annotation will override base script set by Groovy compiler or
CompilerConfiguration of GroovyShell
Example usage:
class CustomScript extends Script {
int getTheMeaningOfLife() { 42 }
}
@BaseScript CustomScript baseScript
assert baseScript == this
assert theMeaningOfLife == 42
assert theMeaningOfLife == baseScript.theMeaningOfLife
In this example, the base script of the current script will be changed to
CustomScript allowing usage of getTheMeaningOfLife()
method. baseScript variable will become typed shortcut for
this object which enables better IDE support.