Search code examples
scalagroovyscriptingclassloader

Is there anything like GroovyScriptEngine and GroovyClassLoader in Scala?


I noticed scala is jsr 223 compliant https://issues.scala-lang.org/browse/SI-874 ... but is it able to do stuff like GroovyScriptEngine ? I consider adding a scala scripting support to our product so that developers could write small apps/components/classes that would be loaded from java application (ideally with reloading possibility). I use GroovyScriptEngine for groovy apps/components/classes, but I can't find anything like that in Scala.

Basicaly I'd need to feed it a directory with scala stuff and it would load all scala classes that would be accessible (or at least one) to java app.

Could you please give me some pointers ? This is the only way to use Scala for us.


Solution

  • Scala Script Engine

    This library dynamically compiles scala source files and loads them as classes. Changed scala files will be recompiled and the changed class with be loaded. Multiple source paths are supported as well as compilation class path and class loading class paths (so that the scripts can load extra libraries).

    Classpath detection can be automatic (effectively using the classpath of the caller) or manual.

    Different compilation and refreshing strategies are provided to suit various purposes.