Skip to content

Commit

Permalink
Cleaned up API to match bld operations aand options APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
ethauvin committed Aug 28, 2024
1 parent 15034b4 commit 2600e74
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/lib/bld/bld-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Apr 02 10:32:44 PDT 2023
bld.downloadExtensionSources=true
bld.downloadLocation=
bld.extension=com.uwyn.rife2:bld-property-file:0.9.6
bld.extension=com.uwyn.rife2:bld-property-file:0.9.7-SNAPSHOT
bld.repositories=MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
bld.version=2.0.1
8 changes: 4 additions & 4 deletions examples/version.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
#Sun Jul 28 22:07:37 PDT 2024
build.date=2024-07-28
#Wed Aug 28 14:44:44 PDT 2024
build.date=2024-08-28
release=beta.20240728220737
version.major=1
version.major=3
version.minor=1
version.patch=20
version.patch=10
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class PropertyFileBuild extends Project {
public PropertyFileBuild() {
pkg = "rife.bld.extension";
name = "bld-property-file";
version = version(0, 9, 6);
version = version(0, 9, 7, "SNAPSHOT");

javaRelease = 17;
downloadSources = true;
Expand Down
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.List;
import java.util.Properties;
Expand Down Expand Up @@ -152,8 +153,26 @@ public PropertyFileOperation file(File file) {
* @return this instance
*/
public PropertyFileOperation file(String file) {
file_ = new File(file);
return this;
return file(new File(file));
}

/**
* Retrieves the location of the {@link java.util.Properties} file to be edited.
*
* @return the properties file
*/
public File file() {
return file_;
}

/**
* Sets the location of the {@link java.util.Properties} file to be edited.
*
* @param file the file to be edited
* @return this instance
*/
public PropertyFileOperation file(Path file) {
return file(file.toFile());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,18 @@ void testExecuteNoProject() {
var op = new PropertyFileOperation();
assertThatCode(op::execute).isInstanceOf(ExitStatusException.class);
}

@Test
void testFile() {
var foo = new File("foo");

var op = new PropertyFileOperation().file("foo");
assertThat(op.file()).as("as string").isEqualTo(foo);

op = new PropertyFileOperation().file(foo);
assertThat(op.file()).as("as file").isEqualTo(foo);

op = new PropertyFileOperation().file(foo.toPath());
assertThat(op.file()).as("as path").isEqualTo(foo);
}
}

0 comments on commit 2600e74

Please sign in to comment.