Interface ScriptInterpreter
-
- All Superinterfaces:
java.lang.AutoCloseable,java.io.Closeable
public interface ScriptInterpreter extends java.io.CloseableDefines a simple abstraction used to plug-in several script interpreters for the pre-/post-build-hooks. Each interpreter implementation should be stateless and support reuse.- Author:
- Benjamin Bentmann
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.lang.ObjectevaluateScript(java.lang.String script, java.util.Map<java.lang.String,?> globalVariables, java.io.PrintStream scriptOutput)Evaluates the specified script.voidsetClassPath(java.util.List<java.lang.String> classPath)Set class path used by interpreted.default voidsetTargetBytecode(java.lang.String version)Sets the target bytecode version for interpreters that support bytecode-level compilation.
-
-
-
Method Detail
-
setClassPath
void setClassPath(java.util.List<java.lang.String> classPath)
Set class path used by interpreted.- Parameters:
classPath- The additional class path for the script interpreter, may benullor empty if only the plugin realm should be used for the script evaluation. If specified, this class path will precede the artifacts from the plugin class path.
-
setTargetBytecode
default void setTargetBytecode(java.lang.String version)
Sets the target bytecode version for interpreters that support bytecode-level compilation. Interpreters that do not compile to a specific bytecode level (for example BeanShell) may ignore this.- Parameters:
version- The target bytecode version, may benullto use the interpreter's own default.
-
evaluateScript
java.lang.Object evaluateScript(java.lang.String script, java.util.Map<java.lang.String,?> globalVariables, java.io.PrintStream scriptOutput) throws ScriptEvaluationExceptionEvaluates the specified script.- Parameters:
script- The script contents to evaluate, must not benull.globalVariables- The global variables (as a mapping from variable name to value) to define for the script, may benullif not used.scriptOutput- A print stream to redirect any output from the script to, may benullto use stdout/stderr.- Returns:
- The return value from the script, can be
null - Throws:
ScriptEvaluationException- If the script evaluation produced an error.
-
-