in src/main/java/org/apache/maven/shared/scriptinterpreter/GroovyScriptInterpreter.java [41:76]
public Object evaluateScript(
String script,
List<String> classPath,
Map<String, ? extends Object> globalVariables,
PrintStream scriptOutput)
throws ScriptEvaluationException {
PrintStream origOut = System.out;
PrintStream origErr = System.err;
try (RootLoader childFirstLoader =
new RootLoader(new URL[] {}, getClass().getClassLoader())) {
if (scriptOutput != null) {
System.setErr(scriptOutput);
System.setOut(scriptOutput);
}
if (classPath != null && !classPath.isEmpty()) {
for (String path : classPath) {
childFirstLoader.addURL(new File(path).toURI().toURL());
}
}
GroovyShell interpreter = new GroovyShell(
childFirstLoader,
new Binding(globalVariables),
new CompilerConfiguration(CompilerConfiguration.DEFAULT));
return interpreter.evaluate(script);
} catch (Throwable e) {
throw new ScriptEvaluationException(e);
} finally {
System.setErr(origErr);
System.setOut(origOut);
}
}