Checkout this for how to maybe do this: https://github.com/GateNLP/gateplugin-Groovy/blob/master/src/main/java/gate/groovy/GroovySupport.java#L70