Elonoa
Elonoa

Reputation: 467

How to force Groovy Script Engine to output compiled classes in files?

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")

Upvotes: 2

Views: 1208

Answers (1)

tim_yates
tim_yates

Reputation: 171114

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.

Upvotes: 1

Related Questions