Class ScriptRunner
java.lang.Object
org.apache.maven.shared.scriptinterpreter.ScriptRunner
- All Implemented Interfaces:
Closeable
,AutoCloseable
Runs pre-/post-build hook scripts.
- Author:
- Benjamin Bentmann
-
Constructor Summary
ConstructorDescriptionCreates a new script runner with BSH and Groovy interpreters. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addScriptInterpreter
(String id, ScriptInterpreter scriptInterpreter) Add new script Interpretervoid
close()
Closes this script interpreter and releases any system resources associated with it.void
run
(String scriptDescription, File basedir, String relativeScriptPath, Map<String, ?> context, ExecutionLogger logger) Runs the specified hook script (after resolution).void
Runs the specified hook script.void
setClassPath
(List<String> classPath) Sets the additional class path for the hook scripts.void
setGlobalVariable
(String name, Object value) Sets a global variable for the script interpreter.void
setScriptEncoding
(String encoding) Sets the file encoding of the hook scripts.
-
Constructor Details
-
ScriptRunner
public ScriptRunner()Creates a new script runner with BSH and Groovy interpreters.
-
-
Method Details
-
setGlobalVariable
Sets a global variable for the script interpreter.- Parameters:
name
- The name of the variable, must not benull
.value
- The value of the variable, may benull
.
-
setClassPath
Sets the additional class path for the hook scripts. Note that the provided list is copied, so any later changes will not affect the scripts.- Parameters:
classPath
- The additional class path for the script interpreter, may benull
or 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.
-
setScriptEncoding
Sets the file encoding of the hook scripts.- Parameters:
encoding
- The file encoding of the hook scripts, may benull
or empty to use the platform's default encoding.
-
close
Closes this script interpreter and releases any system resources associated with it.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- if an I/O error occurs.