diff --git a/.gitignore b/.gitignore
index a2805aa..f301bde 100644
--- a/.gitignore
+++ b/.gitignore
@@ -52,4 +52,7 @@ atlassian-ide-plugin.xml
.idea/sonarlint/
# Editor-based Rest Client
-.idea/httpRequests
\ No newline at end of file
+.idea/httpRequests
+
+# Local Properties
+local.properties
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 8e43730..982b093 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -7,9 +7,15 @@
+
+
+
diff --git a/README.md b/README.md
index ea52dab..b9220a4 100755
--- a/README.md
+++ b/README.md
@@ -29,9 +29,15 @@ constitute a failure.
```java
@BuildCommand
public void startServer() throws Exception {
+ final List 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("cmd", "/c", "stop.bat")
+ .command(cmds)
.fail(ExecFail.STDERR)
.execute();
}
@@ -61,7 +67,7 @@ public void startServer() throws Exception {
new ExecOperation()
.fromProject(this)
.command("touch", "foo.txt")
- .workDir("/tmp")
+ .workDir(System.getProperty("java.io.tmpdir"))
.execute();
}
```
diff --git a/config/pmd.xml b/config/pmd.xml
index 1039e40..c60ff7e 100644
--- a/config/pmd.xml
+++ b/config/pmd.xml
@@ -19,7 +19,6 @@
-
diff --git a/src/main/java/rife/bld/extension/ExecOperation.java b/src/main/java/rife/bld/extension/ExecOperation.java
index cb78a5d..232c29b 100644
--- a/src/main/java/rife/bld/extension/ExecOperation.java
+++ b/src/main/java/rife/bld/extension/ExecOperation.java
@@ -54,6 +54,16 @@ public class ExecOperation extends AbstractOperation {
return this;
}
+ /**
+ * Configures the command and arguments to be executed.
+ *
+ * @see #command(String...)
+ */
+ public ExecOperation command(List args) {
+ args_.addAll(args);
+ return this;
+ }
+
/**
* Executes the command.
*/
diff --git a/src/test/java/rife/bld/extension/ExecOperationTest.java b/src/test/java/rife/bld/extension/ExecOperationTest.java
index 9a01a69..1310726 100644
--- a/src/test/java/rife/bld/extension/ExecOperationTest.java
+++ b/src/test/java/rife/bld/extension/ExecOperationTest.java
@@ -23,6 +23,7 @@ import rife.bld.WebProject;
import java.io.File;
import java.io.IOException;
+import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
@@ -30,6 +31,7 @@ import static org.assertj.core.api.Assertions.assertThatCode;
class ExecOperationTest {
private static final String FOO = "foo";
+ private static final String HELLO = "Hello";
@Test
void testAll() {
@@ -55,6 +57,16 @@ class ExecOperationTest {
assertThat(tmpFile).exists();
}
+ @Test
+ void testCommandList() {
+ assertThatCode(() ->
+ new ExecOperation()
+ .fromProject(new BaseProject())
+ .command(List.of("logger", "-s", HELLO))
+ .fail(ExecFail.STDERR)
+ .execute()).message().startsWith("STDERR -> ").endsWith(HELLO);
+ }
+
@Test
void testException() {
assertThatCode(() ->
@@ -100,9 +112,9 @@ class ExecOperationTest {
assertThatCode(() ->
new ExecOperation()
.fromProject(new BaseProject())
- .command("logger", "-s", "Hello")
+ .command("logger", "-s", HELLO)
.fail(ExecFail.STDERR)
- .execute()).message().startsWith("STDERR -> ").endsWith("Hello");
+ .execute()).message().startsWith("STDERR -> ").endsWith(HELLO);
}
@Test
@@ -110,7 +122,7 @@ class ExecOperationTest {
assertThatCode(() ->
new ExecOperation()
.fromProject(new BaseProject())
- .command("echo", "Hello")
+ .command("echo", HELLO)
.fail(ExecFail.STDOUT)
.execute()).message().isEqualTo("STDOUT -> Hello");
}