String scriptText = "int a = 12;"; ImportCustomizer ic = new ImportCustomizer(); ic.addImports("my.package.MyClass"); CompilerConfiguration cc = new CompilerConfiguration(); cc.addCompilationCustomizers(ic); Binding gb = new Binding(); gb.setVariable("myObject", myObject); GroovyShell gsh = new GroovyShell(gb, cc); gsh.evaluate(scriptText); Object res = gsh.evaluate(scriptText); The development environment says line
gb.setVariable("myObject", myObject); is a mistake. How to fix?
myObjectwhere? - Alexey Shimansky