Command Line Execution Extension for bld https://github.com/rife2/bld-exec
Find a file
Erik C. Thauvin e7d3060649
Display command output asynchronously.
Replaced fail() function with failOnExit().
2024-04-04 18:18:03 -07:00
.github/workflows Bumped worflows actions to the latest versions 2024-04-04 09:43:14 -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 Bumped PMD extension to version 0.9.8 2024-04-04 09:44:36 -07:00
lib/bld Added command timeout 2024-04-04 09:45:16 -07:00
src Display command output asynchronously. 2024-04-04 18:18:03 -07: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 Display command output asynchronously. 2024-04-04 18:18:03 -07: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();
}

Exit Status

Use the failOnExit function to specify whether a command non-zero exit 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();
}

Work Directory

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.