public static ScriptEngine setup(final ScriptEngine groovyScriptEngine) {
        try {
            for (Class<?> c : CoreImports.getClassImports()) {
                groovyScriptEngine.eval("import " + c.getName());
            }

            final Set<Class<?>> staticImports = new HashSet<>();

            for (Enum e : CoreImports.getEnumImports()) {
                staticImports.add(e.getDeclaringClass());
            }

            for (Method m : CoreImports.getMethodImports()) {
                staticImports.add(m.getDeclaringClass());
            }

            for (Field f : CoreImports.getFieldImports()) {
                staticImports.add(f.getDeclaringClass());
            }

            for (Class<?> c : staticImports) {
                groovyScriptEngine.eval("import static " + c.getName() + ".*");
            }

            return groovyScriptEngine;
        } catch (final ScriptException ex) {
            throw new IllegalStateException(ex.getMessage(), ex);
        }
    }
@author Marko A. Rodriguez (http://markorodriguez.com)
@author Stephen Mallette (http://stephen.genoprime.com)
gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyScriptEngineSetup.java