Alexander Suraphel
Alexander Suraphel

Reputation: 10613

What's the difference between GroovyShell and GroovyScriptEngine?

Specifically http://docs.groovy-lang.org/latest/html/api/groovy/util/GroovyScriptEngine.html and http://docs.groovy-lang.org/latest/html/api/groovy/lang/GroovyShell.html. In what situations would you use one over another?

Upvotes: 3

Views: 2387

Answers (1)

cfrick
cfrick

Reputation: 37033

tl;dl: the script engine is for a groovy eco system; the shell for running scripts

The docs explain that in the section Groovy integration mechanisms.

From GroovyScriptEngine

The groovy.util.GroovyScriptEngine class provides a flexible foundation for applications which rely on script reloading and script dependencies. While GroovyShell focuses on standalone Script's and GroovyClassLoader handles dynamic compilation and loading of any Groovy class, the GroovyScriptEngine will add a layer on top of GroovyClassLoader to handle both script dependencies and reloading.

further down the text is an example where a running script engine reloads classes automatically and also dependencies.

Upvotes: 4

Related Questions