diff --git a/src/main/java/rife/bld/extension/ExecOperation.java b/src/main/java/rife/bld/extension/ExecOperation.java index af192d0..3989ead 100644 --- a/src/main/java/rife/bld/extension/ExecOperation.java +++ b/src/main/java/rife/bld/extension/ExecOperation.java @@ -37,7 +37,7 @@ import java.util.logging.Logger; */ public class ExecOperation extends AbstractOperation { private static final Logger LOGGER = Logger.getLogger(ExecOperation.class.getName()); - private final List args_ = new ArrayList<>(); + private final Collection args_ = new ArrayList<>(); private boolean failOnExit_ = true; private BaseProject project_; private int timeout_ = 30; @@ -61,6 +61,16 @@ public class ExecOperation extends AbstractOperation { return this; } + /** + * Returns the command and arguments to be executed. + * + * @return the command and arguments + */ + public Collection command() { + return args_; + } + + /** * Configures the command and arguments to be executed. * @@ -92,7 +102,7 @@ public class ExecOperation extends AbstractOperation { if (workDir.isDirectory()) { var pb = new ProcessBuilder(); pb.inheritIO(); - pb.command(args_); + pb.command(args_.stream().toList()); pb.directory(workDir); if (LOGGER.isLoggable(Level.INFO)) { diff --git a/src/test/java/rife/bld/extension/ExecOperationTest.java b/src/test/java/rife/bld/extension/ExecOperationTest.java index d070e15..5d819b3 100644 --- a/src/test/java/rife/bld/extension/ExecOperationTest.java +++ b/src/test/java/rife/bld/extension/ExecOperationTest.java @@ -31,16 +31,10 @@ class ExecOperationTest { private static final String FOO = "foo"; @Test - void testCat() throws Exception { - var tmpFile = new File("hello.tmp"); - tmpFile.deleteOnExit(); - new ExecOperation() - .fromProject(new Project()) - .timeout(10) - .command("touch", tmpFile.getName()) - .execute(); - - assertThat(tmpFile).exists(); + void testCommand() { + var op = new ExecOperation().fromProject(new WebProject()) + .command(FOO, "bar"); + assertThat(op.command()).isEqualTo(List.of(FOO, "bar")); } @Test