Cleaned up API to match bld operations aand options APIs

This commit is contained in:
Erik C. Thauvin 2024-08-28 14:47:14 -07:00
parent 15034b4363
commit 2600e74be7
Signed by: erik
GPG key ID: 776702A6A2DA330E
5 changed files with 41 additions and 8 deletions

View file

@ -1,6 +1,6 @@
#Sun Apr 02 10:32:44 PDT 2023 #Sun Apr 02 10:32:44 PDT 2023
bld.downloadExtensionSources=true bld.downloadExtensionSources=true
bld.downloadLocation= 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.repositories=MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
bld.version=2.0.1 bld.version=2.0.1

View file

@ -1,7 +1,7 @@
# #
#Sun Jul 28 22:07:37 PDT 2024 #Wed Aug 28 14:44:44 PDT 2024
build.date=2024-07-28 build.date=2024-08-28
release=beta.20240728220737 release=beta.20240728220737
version.major=1 version.major=3
version.minor=1 version.minor=1
version.patch=20 version.patch=10

View file

@ -34,7 +34,7 @@ public class PropertyFileBuild extends Project {
public PropertyFileBuild() { public PropertyFileBuild() {
pkg = "rife.bld.extension"; pkg = "rife.bld.extension";
name = "bld-property-file"; name = "bld-property-file";
version = version(0, 9, 6); version = version(0, 9, 7, "SNAPSHOT");
javaRelease = 17; javaRelease = 17;
downloadSources = true; downloadSources = true;

View file

@ -21,6 +21,7 @@ import rife.bld.operations.AbstractOperation;
import rife.bld.operations.exceptions.ExitStatusException; import rife.bld.operations.exceptions.ExitStatusException;
import java.io.File; import java.io.File;
import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
@ -152,8 +153,26 @@ public class PropertyFileOperation extends AbstractOperation<PropertyFileOperati
* @return this instance * @return this instance
*/ */
public PropertyFileOperation file(String file) { public PropertyFileOperation file(String file) {
file_ = new File(file); return file(new File(file));
return this; }
/**
* 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());
} }
/** /**

View file

@ -84,4 +84,18 @@ class PropertyFileOperationTest {
var op = new PropertyFileOperation(); var op = new PropertyFileOperation();
assertThatCode(op::execute).isInstanceOf(ExitStatusException.class); 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);
}
} }