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 GroovyScriptEngine
does not seem ( from looking at the source ) to use that property of CompilerConfiguration
It would need to be passed in the constructor of the inner ScriptClassLoader
, so that the GroovyClassLoader
that it extends gets the configuration when it is constructed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.