Skip to content

Commit

Permalink
Cleaned up API to match bld operations and options APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
ethauvin committed Aug 27, 2024
1 parent f563cff commit 9548dde
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/bld/java/rife/bld/extension/ExecOperationBuild.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class ExecOperationBuild extends Project {
public ExecOperationBuild() {
pkg = "rife.bld.extension";
name = "ExecOperation";
version = version(1, 0, 2);
version = version(1, 0, 3, "SNAPSHOT");

javaRelease = 17;

Expand All @@ -44,8 +44,8 @@ public ExecOperationBuild() {
scope(compile)
.include(dependency("com.uwyn.rife2", "bld", version(2, 0, 1)));
scope(test)
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 3)))
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 3)))
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 11, 0)))
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 11, 0)))
.include(dependency("org.assertj", "assertj-core", version(3, 26, 3)));

javadocOperation()
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/rife/bld/extension/ExecOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import rife.bld.operations.exceptions.ExitStatusException;

import java.io.File;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
Expand Down Expand Up @@ -57,8 +58,7 @@ public class ExecOperation extends AbstractOperation<ExecOperation> {
* @see #command(Collection)
*/
public ExecOperation command(String... arg) {
args_.addAll(List.of(arg));
return this;
return command(List.of(arg));
}

/**
Expand Down Expand Up @@ -199,6 +199,17 @@ public ExecOperation workDir(File dir) {
return this;
}

/**
* Configures the working directory.
*
* @param dir the directory
* @return this operation instance
*/
public ExecOperation workDir(Path dir) {
return workDir(dir.toFile());
}


/**
* Configures the working directory.
*
Expand Down
11 changes: 10 additions & 1 deletion src/test/java/rife/bld/extension/ExecOperationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,16 @@ void testWorkDir() {
.fromProject(new BaseProject())
.command("echo", FOO)
.workDir(workDir);
assertThat(op.workDir()).isEqualTo(workDir);
assertThat(op.workDir()).as("as file").isEqualTo(workDir);
assertThatCode(op::execute).doesNotThrowAnyException();

var build = "build";
op = op.workDir(build);
assertThat(op.workDir()).as("as string").isEqualTo(new File(build));
assertThatCode(op::execute).doesNotThrowAnyException();

op = op.workDir(workDir.toPath());
assertThat(op.workDir()).as("as path").isEqualTo(workDir);
assertThatCode(op::execute).doesNotThrowAnyException();
}

Expand Down

0 comments on commit 9548dde

Please sign in to comment.