I googled and found out you can make GroovyScriptEngine output scriptCache into class files by setting setTargetDirectory. But when I execute the code something like below from scala, it doesn’t generate class files.
How do you set GroovyScriptEngine to output class files from scripts compiled by GroovyScriptEngine?
var gse = new GroovyScriptEngine()
gse.getConfig().setTargetDirectory("c:/test")
var scriptClass = gse.loadScriptByName("SomeGroovyClass.groovy")
The
GroovyScriptEnginedoes not seem (from looking at the source) to use that property ofCompilerConfigurationIt would need to be passed in the constructor of the inner
ScriptClassLoader, so that theGroovyClassLoaderthat it extends gets the configuration when it is constructed.