Command Line Execution Extension for bld https://github.com/rife2/bld-exec
Find a file
2024-06-21 00:01:08 -07:00
.github/workflows Bumped worflows actions to the latest versions 2024-04-04 09:43:14 -07:00
.idea Bumped bld to version 1.9.1 2024-05-09 21:11:50 -07:00
.vscode Bumped bld to version 1.9.1 2024-05-09 21:11:50 -07:00
config Bumped PMD extension to version 0.9.8 2024-04-04 09:44:36 -07:00
lib/bld Bumped PMD extension to version 1.0.1 2024-06-21 00:00:23 -07:00
src Bumped AssertJ to version 3.26.0 2024-06-21 00:01:08 -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 Bumped bld to version 1.9.1 2024-05-09 21:11:50 -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 Value

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

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.