Skip to content

rife2/bld-exec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.