Skip to content

Instantly share code, notes, and snippets.

@sam
Created February 5, 2016 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sam/8a4739329f2a9a476487 to your computer and use it in GitHub Desktop.
Save sam/8a4739329f2a9a476487 to your computer and use it in GitHub Desktop.
Caching compilation results errors
def compile(): List[CompiledScript] = {
val outputCache = directory / ".cache"
if(!outputCache.exists()) outputCache.mkdirs()
val engine: IMain = new ScriptEngineManager().getEngineByName("scala").asInstanceOf[IMain]
engine.settings.usejavacp.value = true
// TODO: This breaks things. No idea why.
// engine.settings.outdir.value = outputCache.getCanonicalPath
directory.listFiles().toList collect {
case file @ FileExtension("scala") => using(new FileReader(file))(engine.compile)
}
}
/*
I get the following error when calling foreach eval() on the results:
[info] <console>:14: error: not found: value engine
[info] }.asInstanceOf[Object]; def getEngine: javax.script.ScriptEngine = engine }
That source isn't in my own code.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment