I\'m trying to generate a closure from a string. The code inside the closure references a DSL function build(). The errors I\'m getting imply that Groovy is trying to exec
In addition to Michael Easter's answer, you could also pass the script's binding through to the GroovyShell
def build = { -> "BUILD $it" } def shell = new GroovyShell( this.binding ) def c = shell.evaluate( "{ -> build( 'tim_yates' ) }" ) c()