Class ScriptRunner
- java.lang.Object
-
- org.apache.maven.shared.scriptinterpreter.ScriptRunner
-
public class ScriptRunner extends java.lang.Object
Runs pre-/post-build hook scripts.- Version:
- $Id: ScriptRunner.java 1797598 2017-06-04 18:41:18Z hboutemy $
- Author:
- Benjamin Bentmann
-
-
Constructor Summary
Constructors Constructor Description ScriptRunner(org.apache.maven.plugin.logging.Log log)
Creates a new script runner.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addScriptInterpreter(java.lang.String id, ScriptInterpreter scriptInterpreter)
void
run(java.lang.String scriptDescription, java.io.File basedir, java.lang.String relativeScriptPath, java.util.Map<java.lang.String,? extends java.lang.Object> context, ExecutionLogger logger, java.lang.String stage, boolean failOnException)
Runs the specified hook script (after resolution).void
run(java.lang.String scriptDescription, java.io.File scriptFile, java.util.Map<java.lang.String,? extends java.lang.Object> context, ExecutionLogger logger, java.lang.String stage, boolean failOnException)
Runs the specified hook script.void
setClassPath(java.util.List<java.lang.String> classPath)
Sets the additional class path for the hook scripts.void
setGlobalVariable(java.lang.String name, java.lang.Object value)
Sets a global variable for the script interpreter.void
setScriptEncoding(java.lang.String encoding)
Sets the file encoding of the hook scripts.
-
-
-
Method Detail
-
addScriptInterpreter
public void addScriptInterpreter(java.lang.String id, ScriptInterpreter scriptInterpreter)
-
setGlobalVariable
public void setGlobalVariable(java.lang.String name, java.lang.Object value)
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
public void setClassPath(java.util.List<java.lang.String> classPath)
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
public void setScriptEncoding(java.lang.String encoding)
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.
-
run
public void run(java.lang.String scriptDescription, java.io.File basedir, java.lang.String relativeScriptPath, java.util.Map<java.lang.String,? extends java.lang.Object> context, ExecutionLogger logger, java.lang.String stage, boolean failOnException) throws java.io.IOException, RunFailureException
Runs the specified hook script (after resolution).- Parameters:
scriptDescription
- The description of the script to use for logging, must not benull
.basedir
- The base directory of the project, must not benull
.relativeScriptPath
- The path to the script relative to the project base directory, may benull
to skip the script execution and may not have extensions (resolution will search).context
- The key-value storage used to share information between hook scripts, may benull
.logger
- The logger to redirect the script output to, may benull
to use stdout/stderr.stage
- The stage of the build job the script is invoked in, must not benull
. This is for logging purpose only.failOnException
- Iftrue
and the script throws an exception, then aRunFailureException
will be thrown, otherwise aRunErrorException
will be thrown on script exception.- Throws:
java.io.IOException
- If an I/O error occurred while reading the script file.RunFailureException
- If the script did not returntrue
of threw an exception.
-
run
public void run(java.lang.String scriptDescription, java.io.File scriptFile, java.util.Map<java.lang.String,? extends java.lang.Object> context, ExecutionLogger logger, java.lang.String stage, boolean failOnException) throws java.io.IOException, RunFailureException
Runs the specified hook script.- Parameters:
scriptDescription
- The description of the script to use for logging, must not benull
.scriptFile
- The path to the script, may benull
to skip the script execution.context
- The key-value storage used to share information between hook scripts, may benull
.logger
- The logger to redirect the script output to, may benull
to use stdout/stderr.stage
- The stage of the build job the script is invoked in, must not benull
. This is for logging purpose only.failOnException
- Iftrue
and the script throws an exception, then aRunFailureException
will be thrown, otherwise aRunErrorException
will be thrown on script exception.- Throws:
java.io.IOException
- If an I/O error occurred while reading the script file.RunFailureException
- If the script did not returntrue
of threw an exception.
-
-