If I call CompilerConfiguration#setTargetDirectory then GroovyScriptEngine will save .class files for scripts it compiles. However, when creating a new instance of GroovyScriptEngine (e.g., because of application restart) it will not reuse those .class files and instead recompile all scripts. This compilation can be time consuming.
Instead, GroovyScriptEngine#scriptCache can be written and reloaded and CompilerConfiguration#getTargetDirectory could be one of the urls that GroovyClassLoader users. Writing can be done just when a target path is given and CompilerConfiguration#getTargetDirectory is set, reloading can be another public method that users should invoke (e.g., since they know which dump file matches which instance)
It would also be nice if GroovyScriptEngine saved the output of each script as a jar. This will allow deploying pre-compiled jars of some scripts to speed up first usage of applications.