Added opton to add a List via the command method
This commit is contained in:
parent
9843cfeb6b
commit
193c791408
6 changed files with 44 additions and 8 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -52,4 +52,7 @@ atlassian-ide-plugin.xml
|
||||||
.idea/sonarlint/
|
.idea/sonarlint/
|
||||||
|
|
||||||
# Editor-based Rest Client
|
# Editor-based Rest Client
|
||||||
.idea/httpRequests
|
.idea/httpRequests
|
||||||
|
|
||||||
|
# Local Properties
|
||||||
|
local.properties
|
8
.idea/misc.xml
generated
8
.idea/misc.xml
generated
|
@ -7,9 +7,15 @@
|
||||||
<component name="PDMPlugin">
|
<component name="PDMPlugin">
|
||||||
<option name="customRuleSets">
|
<option name="customRuleSets">
|
||||||
<list>
|
<list>
|
||||||
<option value="K:\java\semver\config\pmd.xml" />
|
<option value="$PROJECT_DIR$/config/pmd.xml" />
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
|
<option name="options">
|
||||||
|
<map>
|
||||||
|
<entry key="Statistics URL" value="" />
|
||||||
|
<entry key="Target JDK" value="17" />
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
<option name="skipTestSources" value="false" />
|
<option name="skipTestSources" value="false" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||||
|
|
10
README.md
10
README.md
|
@ -29,9 +29,15 @@ constitute a failure.
|
||||||
```java
|
```java
|
||||||
@BuildCommand
|
@BuildCommand
|
||||||
public void startServer() throws Exception {
|
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()
|
new ExecOperation()
|
||||||
.fromProject(this)
|
.fromProject(this)
|
||||||
.command("cmd", "/c", "stop.bat")
|
.command(cmds)
|
||||||
.fail(ExecFail.STDERR)
|
.fail(ExecFail.STDERR)
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
@ -61,7 +67,7 @@ public void startServer() throws Exception {
|
||||||
new ExecOperation()
|
new ExecOperation()
|
||||||
.fromProject(this)
|
.fromProject(this)
|
||||||
.command("touch", "foo.txt")
|
.command("touch", "foo.txt")
|
||||||
.workDir("/tmp")
|
.workDir(System.getProperty("java.io.tmpdir"))
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
</properties>
|
</properties>
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
|
|
||||||
<!-- CODE STYLE -->
|
<!-- CODE STYLE -->
|
||||||
<rule ref="category/java/codestyle.xml">
|
<rule ref="category/java/codestyle.xml">
|
||||||
<exclude name="AtLeastOneConstructor"/>
|
<exclude name="AtLeastOneConstructor"/>
|
||||||
|
|
|
@ -54,6 +54,16 @@ public class ExecOperation extends AbstractOperation<ExecOperation> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures the command and arguments to be executed.
|
||||||
|
*
|
||||||
|
* @see #command(String...)
|
||||||
|
*/
|
||||||
|
public ExecOperation command(List<String> args) {
|
||||||
|
args_.addAll(args);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the command.
|
* Executes the command.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -23,6 +23,7 @@ import rife.bld.WebProject;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.assertThatCode;
|
import static org.assertj.core.api.Assertions.assertThatCode;
|
||||||
|
@ -30,6 +31,7 @@ import static org.assertj.core.api.Assertions.assertThatCode;
|
||||||
|
|
||||||
class ExecOperationTest {
|
class ExecOperationTest {
|
||||||
private static final String FOO = "foo";
|
private static final String FOO = "foo";
|
||||||
|
private static final String HELLO = "Hello";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testAll() {
|
void testAll() {
|
||||||
|
@ -55,6 +57,16 @@ class ExecOperationTest {
|
||||||
assertThat(tmpFile).exists();
|
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
|
@Test
|
||||||
void testException() {
|
void testException() {
|
||||||
assertThatCode(() ->
|
assertThatCode(() ->
|
||||||
|
@ -100,9 +112,9 @@ class ExecOperationTest {
|
||||||
assertThatCode(() ->
|
assertThatCode(() ->
|
||||||
new ExecOperation()
|
new ExecOperation()
|
||||||
.fromProject(new BaseProject())
|
.fromProject(new BaseProject())
|
||||||
.command("logger", "-s", "Hello")
|
.command("logger", "-s", HELLO)
|
||||||
.fail(ExecFail.STDERR)
|
.fail(ExecFail.STDERR)
|
||||||
.execute()).message().startsWith("STDERR -> ").endsWith("Hello");
|
.execute()).message().startsWith("STDERR -> ").endsWith(HELLO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -110,7 +122,7 @@ class ExecOperationTest {
|
||||||
assertThatCode(() ->
|
assertThatCode(() ->
|
||||||
new ExecOperation()
|
new ExecOperation()
|
||||||
.fromProject(new BaseProject())
|
.fromProject(new BaseProject())
|
||||||
.command("echo", "Hello")
|
.command("echo", HELLO)
|
||||||
.fail(ExecFail.STDOUT)
|
.fail(ExecFail.STDOUT)
|
||||||
.execute()).message().isEqualTo("STDOUT -> Hello");
|
.execute()).message().isEqualTo("STDOUT -> Hello");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue