bld Command Line Execution Extension
To install, please refer to the extensions documentation.
To execute a command at the command line, add the following to your build file:
@BuildCommand
public void startServer() throws Exception {
new ExecOperation()
.fromProject(this)
.command("./start.sh", "--port", "8080")
.execute();
}
Use the failOnExit
function to specify whether a command non-zero exit value (status) constitutes a failure.
@BuildCommand
public void startServer() throws Exception {
final List<String> cmds;
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
cmds = List.of("cmd", "/c", "stop.bat");
} else {
cmds = List.of("./stop.sh");
}
new ExecOperation()
.fromProject(this)
.command(cmds)
.failOneExit(false)
.execute();
}
You can also specify the work directory:
@BuildCommand
public void startServer() throws Exception {
new ExecOperation()
.fromProject(this)
.command("touch", "foo.txt")
.workDir(System.getProperty("java.io.tmpdir"))
.execute();
}
Please check the ExecOperation documentation for all available configuration options.