Search code examples
groovygroovyshell

Which maven dependency to include for evaluating groovy scripts in java application


I've added the ability to parse and evaluate groovy scripts inside my java application using GroovyShell. Which maven artifact is the bare minimum to include in my build?

I know that the groovy-all will definitely contain everything I need, but I'm guessing that there is a smaller package I could use as well?


Solution

  • groovy-jsr223 is the JSR-223 Engine implementation, and it support evaluation of groovy scripts via JSR-223 standard interface.

    ScriptEngine scriptEngine = new ScriptEngineManager().getEngineByName("groovy");
    
    <dependency>
       <groupId>org.codehaus.groovy</groupId>
       <artifactId>groovy-jsr223</artifactId>
       <version>2.4.6</version>
    </dependency>