Command Line Execution Extension for bld https://github.com/rife2/bld-exec
Find a file
2025-03-18 23:35:39 -07:00
.github/workflows JDK 24 2025-03-18 23:35:39 -07:00
.idea Update copyright 2025-02-25 10:02:30 -08:00
.vscode Bump bld to version 2.2.1 2025-02-25 09:57:17 -08:00
config Updated dependencies 2024-10-27 17:07:17 -07:00
lib/bld Bump PMD extension to version 1.2.1 2025-03-18 12:48:20 -07:00
src Bump JUnit to version 5.12.1 2025-03-18 12:48:34 -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 Add generic installation instructions 2025-03-18 12:49:48 -07:00

bld Command Line Execution Extension

License Java bld Release Snapshot GitHub CI

To install the latest version, add the following to the lib/bld/bld-wrapper.properties file:

bld.extension-exec=com.uwyn.rife2:bld-exec

For more information, please refer to the extensions documentation.

Execute a Command

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.