Command Line Execution Extension for bld https://github.com/rife2/bld-exec
Find a file
2024-03-21 13:59:50 -07:00
.github/workflows Added JDK 22 to CI 2024-03-21 13:59:50 -07:00
.idea Bumped to bld 1.9.0 2024-02-26 10:39:27 -08:00
.vscode Bumped to bld 1.9.0 2024-02-26 10:39:27 -08:00
config Added opton to add a List via the command method 2023-08-27 16:46:47 -07:00
lib/bld Added JDK 22 to CI 2024-03-21 13:59:50 -07:00
src Bumped to bld 1.9.0 2024-02-26 10:39:27 -08:00
.gitignore Added opton to add a List via the command method 2023-08-27 16:46:47 -07:00
bld Initial commit 2023-08-27 09:37:13 -07:00
bld.bat Initial commit 2023-08-27 09:37:13 -07:00
LICENSE.txt Initial commit 2023-08-27 09:37:13 -07:00
README.md Bumped to bld 1.9.0 2024-02-26 10:39:27 -08:00

bld Command Line Execution Extension

License Java bld Release Snapshot GitHub CI

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();
}

Failure Modes

Use the fail function to specify whether data returned to the standard streams and/or an abnormal exit value constitute 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)
            .fail(ExecFail.STDERR)
            .execute();
}

The following predefined values are available:

Name Failure When
ExecFail.EXIT Exit value > 0
ExecFail.NORMAL Exit value > 0 or any data to the standard error stream (stderr)
ExecFail.OUTPUT Any data to the standard output stream (stdout) or stderr.
ExecFail.STDERR Any data to stderr.
ExecFail.STDOUT Any data to stdout.
ExecFail.ALL Any of the conditions above.
ExecFail.NONE Never fails.

ExecFail.NORMAL is the default value.

Working Directory

You can also specify the working 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.