diff --git a/examples/README.md b/examples/README.md index 13b19da..ede07c3 100644 --- a/examples/README.md +++ b/examples/README.md @@ -3,17 +3,3 @@ ```console ./bld compile run ``` - -# Update Version Properties - -```console -./bld update-major run -./bld update-minor run -./bld update-patch run -``` - -# Delete Version Properties - -```console -./bld delete-version run -``` \ No newline at end of file diff --git a/examples/lib/bld/bld-wrapper.jar b/examples/lib/bld/bld-wrapper.jar index d0dd498..dd5ee65 100644 Binary files a/examples/lib/bld/bld-wrapper.jar and b/examples/lib/bld/bld-wrapper.jar differ diff --git a/examples/lib/bld/bld-wrapper.properties b/examples/lib/bld/bld-wrapper.properties index 0af2487..014a912 100644 --- a/examples/lib/bld/bld-wrapper.properties +++ b/examples/lib/bld/bld-wrapper.properties @@ -1,6 +1,6 @@ #Sun Apr 02 10:32:44 PDT 2023 +bld.extension=com.uwyn.rife2:bld-property-file:0.9.5 +bld.repositories=MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES bld.downloadExtensionSources=true bld.downloadLocation= -bld.extension=com.uwyn.rife2:bld-property-file:0.9.6-SNAPSHOT -bld.repositories=MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES bld.version=1.9.1 diff --git a/examples/src/bld/java/com/example/PropertyFileExampleBuild.java b/examples/src/bld/java/com/example/PropertyFileExampleBuild.java index c004cc1..8b8ffca 100644 --- a/examples/src/bld/java/com/example/PropertyFileExampleBuild.java +++ b/examples/src/bld/java/com/example/PropertyFileExampleBuild.java @@ -50,7 +50,7 @@ public class PropertyFileExampleBuild extends Project { new PropertyFileExampleBuild().start(args); } - @BuildCommand(value = "update-major", summary = "Updates major version") + @BuildCommand(summary = "Updates major version") public void updateMajor() throws Exception { new PropertyFileOperation() .fromProject(this) @@ -66,7 +66,7 @@ public class PropertyFileExampleBuild extends Project { .execute(); } - @BuildCommand(value = "update-minor", summary = "Updates minor version") + @BuildCommand(summary = "Updates minor version") public void updateMinor() throws Exception { new PropertyFileOperation() .fromProject(this) @@ -82,7 +82,7 @@ public class PropertyFileExampleBuild extends Project { .execute(); } - @BuildCommand(value = "update-patch", summary = "Updates patch version") + @BuildCommand(summary = "Updates patch version") public void updatePatch() throws Exception { new PropertyFileOperation() .fromProject(this) @@ -98,7 +98,7 @@ public class PropertyFileExampleBuild extends Project { .execute(); } - @BuildCommand(value = "update-release", summary = "Updates the release") + @BuildCommand(summary = "Updates the release") public void updateRelease() throws Exception { new PropertyFileOperation() .fromProject(this) @@ -110,7 +110,7 @@ public class PropertyFileExampleBuild extends Project { .execute(); } - @BuildCommand(value = "delete-version", summary = "Delete version properties") + @BuildCommand(summary = "Delete version properties") public void deleteVersion() throws Exception { new PropertyFileOperation() .fromProject(this) diff --git a/lib/bld/bld-wrapper.jar b/lib/bld/bld-wrapper.jar index d0dd498..1a3d0aa 100644 Binary files a/lib/bld/bld-wrapper.jar and b/lib/bld/bld-wrapper.jar differ diff --git a/lib/bld/bld-wrapper.properties b/lib/bld/bld-wrapper.properties index 7a65d7b..6e26fef 100644 --- a/lib/bld/bld-wrapper.properties +++ b/lib/bld/bld-wrapper.properties @@ -1,7 +1,7 @@ bld.downloadExtensionJavadoc=false bld.downloadExtensionSources=true -bld.downloadLocation= +bld.extension-pmd=com.uwyn.rife2:bld-pmd:0.9.9 bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.5 -bld.extension-pmd=com.uwyn.rife2:bld-pmd:1.1.0 bld.repositories=MAVEN_CENTRAL,MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES +bld.downloadLocation= bld.version=1.9.1 diff --git a/src/main/java/rife/bld/extension/propertyfile/Entry.java b/src/main/java/rife/bld/extension/propertyfile/Entry.java index 379255c..816ce21 100644 --- a/src/main/java/rife/bld/extension/propertyfile/Entry.java +++ b/src/main/java/rife/bld/extension/propertyfile/Entry.java @@ -53,7 +53,7 @@ public class Entry extends EntryBase { * @return the entry */ public Entry delete() { - setDelete(); + setDelete(true); return this; } diff --git a/src/main/java/rife/bld/extension/propertyfile/EntryBase.java b/src/main/java/rife/bld/extension/propertyfile/EntryBase.java index b724ed3..b381b0f 100644 --- a/src/main/java/rife/bld/extension/propertyfile/EntryBase.java +++ b/src/main/java/rife/bld/extension/propertyfile/EntryBase.java @@ -28,15 +28,15 @@ import java.util.function.IntFunction; */ @SuppressWarnings("PMD.DataClass") public class EntryBase { - private IntFunction calc_; - private Object defaultValue_; - private boolean isDelete_; - private String key_; - private String modifyValue_ = ""; - private BiFunction modify_; - private Object newValue_; - private String pattern_ = ""; - private EntryDate.Units unit_ = EntryDate.Units.DAY; + private IntFunction calc; + private Object defaultValue; + private boolean isDelete; + private String key; + private BiFunction modify; + private String modifyValue = ""; + private Object newValue; + private String pattern = ""; + private EntryDate.Units unit = EntryDate.Units.DAY; /** * Creates a new {@link EntryBase entry}. @@ -44,7 +44,7 @@ public class EntryBase { * @param key the required property key */ public EntryBase(String key) { - key_ = key; + this.key = key; } /** @@ -53,7 +53,7 @@ public class EntryBase { * @return the calc function */ protected IntFunction getCalc() { - return calc_; + return calc; } /** @@ -62,7 +62,7 @@ public class EntryBase { * @return the default value */ protected Object getDefaultValue() { - return defaultValue_; + return defaultValue; } /** @@ -71,7 +71,7 @@ public class EntryBase { * @return the key */ protected String getKey() { - return key_; + return key; } /** @@ -80,16 +80,16 @@ public class EntryBase { * @return the modify function */ protected BiFunction getModify() { - return modify_; + return modify; } /** - * Returns the value to be used in the {@link #modify_} function. + * Returns the value to be used in the {@link #modify} function. * * @return the modify value */ protected String getModifyValue() { - return modifyValue_; + return modifyValue; } /** @@ -98,7 +98,7 @@ public class EntryBase { * @return the new value */ public Object getNewValue() { - return newValue_; + return newValue; } /** @@ -107,7 +107,7 @@ public class EntryBase { * @return the pattern */ protected String getPattern() { - return pattern_; + return pattern; } /** @@ -116,7 +116,7 @@ public class EntryBase { * @return the unit */ protected EntryDate.Units getUnit() { - return unit_; + return unit; } /** @@ -125,7 +125,7 @@ public class EntryBase { * @return {@code true} or {@code false} */ protected boolean isDelete() { - return isDelete_; + return isDelete; } /** @@ -136,7 +136,7 @@ public class EntryBase { */ @SuppressWarnings("unused") public EntryBase key(String key) { - key_ = key; + setKey(key); return this; } @@ -146,7 +146,7 @@ public class EntryBase { * @param calc the calc function */ protected void setCalc(IntFunction calc) { - calc_ = calc; + this.calc = calc; } /** @@ -155,14 +155,16 @@ public class EntryBase { * @param defaultValue the default value */ protected void setDefaultValue(Object defaultValue) { - defaultValue_ = defaultValue; + this.defaultValue = defaultValue; } /** - * Sets the {@link java.util.Properties property} to be deleted. + * Sets whether the {@link java.util.Properties property} should be deleted. + * + * @param delete {@code true} or {@code false} */ - protected void setDelete() { - isDelete_ = true; + protected void setDelete(boolean delete) { + isDelete = delete; } /** @@ -171,7 +173,7 @@ public class EntryBase { * @param key the {@link java.util.Properties property} key */ protected void setKey(String key) { - key_ = key; + this.key = key; } /** @@ -180,7 +182,7 @@ public class EntryBase { * @param modify the modify function */ protected void setModify(BiFunction modify) { - modify_ = modify; + this.modify = modify; } /** @@ -190,8 +192,8 @@ public class EntryBase { * @param modify the modify function */ protected void setModify(String value, BiFunction modify) { - modifyValue_ = value; - modify_ = modify; + this.modifyValue = value; + this.modify = modify; } /** @@ -200,7 +202,7 @@ public class EntryBase { * @param value the modify value. */ protected void setModifyValue(String value) { - modifyValue_ = value; + this.modifyValue = value; } /** @@ -209,7 +211,7 @@ public class EntryBase { * @param newValue the new value */ public void setNewValue(Object newValue) { - newValue_ = newValue; + this.newValue = newValue; } /** @@ -219,7 +221,7 @@ public class EntryBase { * @param pattern the pattern */ protected void setPattern(String pattern) { - pattern_ = pattern; + this.pattern = pattern; } /** @@ -228,6 +230,6 @@ public class EntryBase { * @param unit the {@link EntryDate.Units unit} */ protected void setUnit(EntryDate.Units unit) { - unit_ = unit; + this.unit = unit; } } diff --git a/src/main/java/rife/bld/extension/propertyfile/EntryDate.java b/src/main/java/rife/bld/extension/propertyfile/EntryDate.java index a25b0e1..4d7fba3 100644 --- a/src/main/java/rife/bld/extension/propertyfile/EntryDate.java +++ b/src/main/java/rife/bld/extension/propertyfile/EntryDate.java @@ -54,7 +54,7 @@ public class EntryDate extends EntryBase { * @return this instance */ public EntryDate delete() { - setDelete(); + setDelete(true); return this; } diff --git a/src/main/java/rife/bld/extension/propertyfile/EntryInt.java b/src/main/java/rife/bld/extension/propertyfile/EntryInt.java index 54226f4..753d3e7 100644 --- a/src/main/java/rife/bld/extension/propertyfile/EntryInt.java +++ b/src/main/java/rife/bld/extension/propertyfile/EntryInt.java @@ -63,7 +63,7 @@ public class EntryInt extends EntryBase { * @return this instance */ public EntryInt delete() { - setDelete(); + setDelete(true); return this; } diff --git a/src/main/java/rife/bld/extension/propertyfile/PropertyFileOperation.java b/src/main/java/rife/bld/extension/propertyfile/PropertyFileOperation.java index 0ecf5d7..e01cb11 100644 --- a/src/main/java/rife/bld/extension/propertyfile/PropertyFileOperation.java +++ b/src/main/java/rife/bld/extension/propertyfile/PropertyFileOperation.java @@ -31,11 +31,11 @@ import java.util.Properties; * @since 1.0 */ public class PropertyFileOperation extends AbstractOperation { - private final List entries_ = new ArrayList<>(); - private String comment_ = ""; - private boolean failOnWarning_; - private File file_; - private BaseProject project_; + private final List entries = new ArrayList<>(); + private String comment = ""; + private boolean failOnWarning; + private File file; + private BaseProject project; /** * Sets the comment to be inserted at the top of the {@link java.util.Properties} file. @@ -43,8 +43,9 @@ public class PropertyFileOperation extends AbstractOperation c + 2)) - .execute(); - - p.load(Files.newInputStream(tmpFile.toPath())); - assertThat(p.getProperty("version.major")).as("major+2").isEqualTo("3"); - - new PropertyFileOperation() - .fromProject(new Project()) - .file(tmpFile) - .entry(new EntryInt("build.date").delete()) - .execute(); - - p.clear(); - p.load(Files.newInputStream(tmpFile.toPath())); - - assertThat(p.getProperty("build.date")).as("dalete build.date").isNull(); - assertThat(p).as("version keys").containsKeys("version.major", "version.minor", "version.patch"); - } -} diff --git a/src/test/java/rife/bld/extension/propertyfile/PropertyFileUtilsTest.java b/src/test/java/rife/bld/extension/propertyfile/PropertyFileUtilsTest.java index 3bce5aa..d64e767 100644 --- a/src/test/java/rife/bld/extension/propertyfile/PropertyFileUtilsTest.java +++ b/src/test/java/rife/bld/extension/propertyfile/PropertyFileUtilsTest.java @@ -58,6 +58,7 @@ class PropertyFileUtilsTest { } @Test + @SuppressWarnings("PMD.SignatureDeclareThrowsException") void parseDateSub() throws Exception { var entryDate = newEntryDate(); entryDate.setCalc(SUB); @@ -83,6 +84,7 @@ class PropertyFileUtilsTest { } @Test + @SuppressWarnings("PMD.SignatureDeclareThrowsException") void parseIntSubTest() throws Exception { var entryInt = newEntryInt(); entryInt.calc(SUB); @@ -146,6 +148,7 @@ class PropertyFileUtilsTest { } @Test + @SuppressWarnings("PMD.SignatureDeclareThrowsException") void parseTimeTest() throws Exception { var entry = new EntryDate("time").pattern("m"); var time = LocalTime.now(); @@ -162,6 +165,7 @@ class PropertyFileUtilsTest { } @Test + @SuppressWarnings("PMD.SignatureDeclareThrowsException") void processDateAddTest() throws Exception { var entryDate = newEntryDate(); entryDate.setCalc(ADD); @@ -185,6 +189,7 @@ class PropertyFileUtilsTest { } @Test + @SuppressWarnings("PMD.SignatureDeclareThrowsException") void processIntAddTest() throws Exception { var entryInt = newEntryInt(); entryInt.calc(ADD); @@ -228,6 +233,7 @@ class PropertyFileUtilsTest { } @Test + @SuppressWarnings("PMD.SignatureDeclareThrowsException") void savePropertiesTest() throws Exception { var p = new Properties(); var test = "test";