A library that runs Groovy scripts from Java code. Maven plugins use it to run the scripts that belong to a build: the Maven Invoker Plugin runs the selector, pre-build and post-build scripts of each integration test with it.
ScriptRunner finds a script by name, passes it variables and a shared
context, puts extra entries on its classpath and captures its output in a log
file. BeanShell scripts are deprecated since 1.10 and still run, with a warning.
- Documentation: https://maven.apache.org/shared/maven-script-interpreter/
- Issues: https://github.com/apache/maven-script-interpreter/issues
- Security reports: see SECURITY.md; never a public issue
- Contributing: see CONTRIBUTING.md and AGENTS.md
The library needs Java 8 or later and runs scripts with Groovy 4.
try (ScriptRunner scriptRunner = new ScriptRunner()) {
scriptRunner.run("post-build script", basedir, "verify", context, new FileLogger(logFile));
}This runs verify.groovy from basedir. The run fails with a ScriptException
when the script throws, or returns anything other than true or nothing.
mvn verify