Skip to content

Commit 650bb81

Browse files
committed
Upgrade to bld 1.7.1
1 parent 3a0144e commit 650bb81

File tree

9 files changed

+105
-102
lines changed

9 files changed

+105
-102
lines changed

.idea/misc.xml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
44
[![Java](https://img.shields.io/badge/java-17%2B-blue)](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)
5-
[![bld](https://img.shields.io/badge/1.7.0-FA9052?label=bld&labelColor=2392FF)](https://rife2.com/bld)
5+
[![bld](https://img.shields.io/badge/1.7.1-FA9052?label=bld&labelColor=2392FF)](https://rife2.com/bld)
66
[![Release](https://flat.badgen.net/maven/v/metadata-url/repo.rife2.com/releases/com/uwyn/rife2/bld-property-file/maven-metadata.xml?color=blue)](https://repo.rife2.com/#/releases/com/uwyn/rife2/bld-property-file)
77
[![Snapshot](https://flat.badgen.net/maven/v/metadata-url/repo.rife2.com/snapshots/com/uwyn/rife2/bld-property-file/maven-metadata.xml?label=snapshot)](https://repo.rife2.com/#/snapshots/com/uwyn/rife2/bld-property-file)
88
[![GitHub CI](https://github.com/rife2/bld-property-file/actions/workflows/bld.yml/badge.svg)](https://github.com/rife2/bld-property-file/actions/workflows/bld.yml)

config/pmd.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<exclude name="ClassNamingConventions"/>
2727
<exclude name="ConfusingTernary"/>
2828
<exclude name="CommentDefaultAccessModifier"/>
29-
<exclude name="DefaultPackage"/>
3029
<exclude name="FieldNamingConventions"/>
3130
<exclude name="LocalVariableCouldBeFinal"/>
3231
<exclude name="LongVariable"/>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Sun Apr 02 10:32:44 PDT 2023
2-
bld.extension=com.uwyn.rife2:bld-property-file:0.9.2-SNAPSHOT
3-
bld.repositories=MAVEN_LOCAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
2+
bld.extension=com.uwyn.rife2:bld-property-file:0.9.2
3+
bld.repositories=RIFE2_SNAPSHOTS,RIFE2_RELEASES,MAVEN_CENTRAL
44
bld.downloadExtensionSources=true
55
bld.downloadLocation=
6-
bld.version=1.7.0
6+
bld.version=1.7.1

lib/bld/bld-wrapper.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
bld.downloadExtensionJavadoc=false
22
bld.downloadExtensionSources=true
3-
bld.extension-pmd=com.uwyn.rife2:bld-pmd:0.9.1-SNAPSHOT
4-
bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.0-SNAPSHOT
5-
bld.repositories=MAVEN_LOCAL,RIFE2_SNAPSHOTS,MAVEN_CENTRAL,RIFE2_RELEASES
3+
bld.extension-pmd=com.uwyn.rife2:bld-pmd:0.9.2
4+
bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.0
5+
bld.repositories=RIFE2_SNAPSHOTS,RIFE2_RELEASES,MAVEN_CENTRAL
66
bld.downloadLocation=
7-
bld.version=1.7.0
7+
bld.version=1.7.1

src/bld/java/rife/bld/extension/propertyfile/PropertyFileBuild.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ public PropertyFileBuild() {
2828
autoDownloadPurge = true;
2929
repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES);
3030

31-
var rife2 = version(1,7,0);
31+
var rife2 = version(1, 7, 0);
3232
scope(compile)
3333
.include(dependency("com.uwyn.rife2", "rife2", rife2))
34-
.include(dependency("com.uwyn.rife2", "bld", rife2));
34+
.include(dependency("com.uwyn.rife2", "bld", version(1, 7, 1)));
3535
scope(test)
3636
.include(dependency("org.jsoup", "jsoup", version(1, 16, 1)))
3737
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 0)))
@@ -76,7 +76,7 @@ public void jacoco() throws IOException {
7676
}
7777

7878
@BuildCommand(summary = "Runs PMD analysis")
79-
public void pmd() throws Exception {
79+
public void pmd() {
8080
new PmdOperation()
8181
.fromProject(this)
8282
.failOnViolation(true)

src/main/java/rife/bld/extension/propertyfile/EntryBase.java

Lines changed: 71 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
* @author <a href="https://github.com/gbevin">Geert Bevin</a>
2727
* @since 1.0
2828
*/
29+
@SuppressWarnings("PMD.DataClass")
2930
public class EntryBase {
3031
private IntFunction<Integer> calc;
3132
private Object defaultValue;
@@ -53,91 +54,41 @@ protected IntFunction<Integer> getCalc() {
5354
return calc;
5455
}
5556

56-
/**
57-
* Sets the calculation function.
58-
*/
59-
protected void setCalc(IntFunction<Integer> calc) {
60-
this.calc = calc;
61-
}
62-
6357
/**
6458
* Returns the default value.
6559
*/
6660
protected Object getDefaultValue() {
6761
return defaultValue;
6862
}
6963

70-
/**
71-
* Sets the initial value to set the {@link java.util.Properties property} to, if not already defined.
72-
*
73-
* @param defaultValue the default value
74-
*/
75-
protected void setDefaultValue(Object defaultValue) {
76-
this.defaultValue = defaultValue;
77-
}
78-
7964
/**
8065
* Returns the key of the {@link java.util.Properties property}.
8166
*/
8267
protected String getKey() {
8368
return key;
8469
}
8570

86-
/**
87-
* Sets the key of the {@link java.util.Properties property}.
88-
*
89-
* @param key the {@link java.util.Properties property} key
90-
*/
91-
protected void setKey(String key) {
92-
this.key = key;
93-
}
94-
9571
/**
9672
* Returns the modify function.
9773
*/
9874
protected BiFunction<String, String, String> getModify() {
9975
return modify;
10076
}
10177

102-
/**
103-
* Sets the modify function.
104-
*/
105-
protected void setModify(BiFunction<String, String, String> modify) {
106-
this.modify = modify;
107-
}
108-
10978
/**
11079
* Returns the value to be used in the {@link #modify} function.
11180
*/
11281
protected String getModifyValue() {
11382
return modifyValue;
11483
}
11584

116-
/**
117-
* Sets the modify value.
118-
*
119-
* @param value the modify value.
120-
*/
121-
protected void setModifyValue(String value) {
122-
this.modifyValue = value;
123-
}
124-
12585
/**
12686
* Returns the new value to set the {@link java.util.Properties property)} to.
12787
*/
12888
public Object getNewValue() {
12989
return newValue;
13090
}
13191

132-
/**
133-
* Sets a new value for {@link java.util.Properties property}.
134-
*
135-
* @param newValue the new value
136-
*/
137-
public void setNewValue(Object newValue) {
138-
this.newValue = newValue;
139-
}
140-
14192
/**
14293
* Returns the pattern.
14394
*/
@@ -146,36 +97,44 @@ protected String getPattern() {
14697
}
14798

14899
/**
149-
* Sets the {@link java.text.DecimalFormat DecimalFormat} or {@link java.time.format.DateTimeFormatter DateTimeFormatter}
150-
* pattern to be used with {@link EntryDate} or {@link EntryInt} respectively.
151-
*
152-
* @param pattern the pattern
100+
* Returns the {@link EntryDate.Units unit}.
153101
*/
154-
protected void setPattern(String pattern) {
155-
this.pattern = pattern;
102+
protected EntryDate.Units getUnit() {
103+
return unit;
156104
}
157105

158106
/**
159-
* Returns the {@link EntryDate.Units unit}.
107+
* Returns {@code true} if the {@link java.util.Properties property} is to be deleted.
160108
*/
161-
protected EntryDate.Units getUnit() {
162-
return unit;
109+
protected boolean isDelete() {
110+
return isDelete;
163111
}
164112

165113
/**
166-
* Sets the {@link EntryDate.Units unit} value to apply to calculations.
114+
* Sets the key of the {@link java.util.Properties property}.
167115
*
168-
* @param unit the {@link EntryDate.Units unit}
116+
* @param key the {@link java.util.Properties property} key
169117
*/
170-
protected void setUnit(EntryDate.Units unit) {
171-
this.unit = unit;
118+
@SuppressWarnings("unused")
119+
public EntryBase key(String key) {
120+
setKey(key);
121+
return this;
172122
}
173123

174124
/**
175-
* Returns {@code true} if the {@link java.util.Properties property} is to be deleted.
125+
* Sets the calculation function.
176126
*/
177-
protected boolean isDelete() {
178-
return isDelete;
127+
protected void setCalc(IntFunction<Integer> calc) {
128+
this.calc = calc;
129+
}
130+
131+
/**
132+
* Sets the initial value to set the {@link java.util.Properties property} to, if not already defined.
133+
*
134+
* @param defaultValue the default value
135+
*/
136+
protected void setDefaultValue(Object defaultValue) {
137+
this.defaultValue = defaultValue;
179138
}
180139

181140
/**
@@ -190,10 +149,15 @@ protected void setDelete(boolean delete) {
190149
*
191150
* @param key the {@link java.util.Properties property} key
192151
*/
193-
@SuppressWarnings("unused")
194-
public EntryBase key(String key) {
195-
setKey(key);
196-
return this;
152+
protected void setKey(String key) {
153+
this.key = key;
154+
}
155+
156+
/**
157+
* Sets the modify function.
158+
*/
159+
protected void setModify(BiFunction<String, String, String> modify) {
160+
this.modify = modify;
197161
}
198162

199163
/**
@@ -205,4 +169,41 @@ protected void setModify(String value, BiFunction<String, String, String> modify
205169
this.modifyValue = value;
206170
this.modify = modify;
207171
}
172+
173+
/**
174+
* Sets the modify value.
175+
*
176+
* @param value the modify value.
177+
*/
178+
protected void setModifyValue(String value) {
179+
this.modifyValue = value;
180+
}
181+
182+
/**
183+
* Sets a new value for {@link java.util.Properties property}.
184+
*
185+
* @param newValue the new value
186+
*/
187+
public void setNewValue(Object newValue) {
188+
this.newValue = newValue;
189+
}
190+
191+
/**
192+
* Sets the {@link java.text.DecimalFormat DecimalFormat} or {@link java.time.format.DateTimeFormatter DateTimeFormatter}
193+
* pattern to be used with {@link EntryDate} or {@link EntryInt} respectively.
194+
*
195+
* @param pattern the pattern
196+
*/
197+
protected void setPattern(String pattern) {
198+
this.pattern = pattern;
199+
}
200+
201+
/**
202+
* Sets the {@link EntryDate.Units unit} value to apply to calculations.
203+
*
204+
* @param unit the {@link EntryDate.Units unit}
205+
*/
206+
protected void setUnit(EntryDate.Units unit) {
207+
this.unit = unit;
208+
}
208209
}

src/main/java/rife/bld/extension/propertyfile/PropertyFileUtils.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.text.ParseException;
2626
import java.time.*;
2727
import java.time.format.DateTimeFormatter;
28-
import java.time.temporal.ChronoUnit;
2928
import java.util.Calendar;
3029
import java.util.Date;
3130
import java.util.Properties;
@@ -95,11 +94,11 @@ public static boolean loadProperties(String command, File file, Properties p) th
9594
* @param p the {@link Properties property}
9695
* @param entry the {@link Entry} containing the {@link Properties property} edits
9796
*/
98-
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
97+
@SuppressWarnings({"PMD.SignatureDeclareThrowsException", "PMD.ExceptionAsFlowControl"})
9998
public static boolean processDate(String command, Properties p, EntryDate entry, boolean failOnWarning)
10099
throws Exception {
101100
var success = true;
102-
var value = PropertyFileUtils.currentValue(null, entry.getDefaultValue(),
101+
var value = currentValue(null, entry.getDefaultValue(),
103102
entry.getNewValue());
104103

105104
var pattern = entry.getPattern();
@@ -159,19 +158,19 @@ public static boolean processDate(String command, Properties p, EntryDate entry,
159158
} else if (value instanceof ZonedDateTime) {
160159
if (offset != 0) {
161160
if (unit == EntryDate.Units.DAY) {
162-
value = ((ZonedDateTime) value).plus(offset, ChronoUnit.DAYS);
161+
value = ((ZonedDateTime) value).plusDays(offset);
163162
} else if (unit == EntryDate.Units.MONTH) {
164-
value = ((ZonedDateTime) value).plus(offset, ChronoUnit.MONTHS);
163+
value = ((ZonedDateTime) value).plusMonths(offset);
165164
} else if (unit == EntryDate.Units.WEEK) {
166-
value = ((ZonedDateTime) value).plus(offset, ChronoUnit.WEEKS);
165+
value = ((ZonedDateTime) value).plusWeeks(offset);
167166
} else if (unit == EntryDate.Units.YEAR) {
168-
value = ((ZonedDateTime) value).plus(offset, ChronoUnit.YEARS);
167+
value = ((ZonedDateTime) value).plusYears(offset);
169168
} else if (unit == EntryDate.Units.SECOND) {
170169
value = ((ZonedDateTime) value).plusSeconds(offset);
171170
} else if (unit == EntryDate.Units.MINUTE) {
172-
value = ((ZonedDateTime) value).plus(offset, ChronoUnit.MINUTES);
171+
value = ((ZonedDateTime) value).plusMinutes(offset);
173172
} else if (unit == EntryDate.Units.HOUR) {
174-
value = ((ZonedDateTime) value).plus(offset, ChronoUnit.HOURS);
173+
value = ((ZonedDateTime) value).plusHours(offset);
175174
}
176175
}
177176
parsedValue = dtf.format((ZonedDateTime) value);
@@ -204,7 +203,7 @@ public static boolean processInt(String command, Properties p, EntryInt entry, b
204203
int intValue = 0;
205204
try {
206205
var fmt = new DecimalFormat(entry.getPattern());
207-
var value = PropertyFileUtils.currentValue(p.getProperty(entry.getKey()), entry.getDefaultValue(),
206+
var value = currentValue(p.getProperty(entry.getKey()), entry.getDefaultValue(),
208207
entry.getNewValue());
209208

210209
if (value != null) {
@@ -231,8 +230,7 @@ public static boolean processInt(String command, Properties p, EntryInt entry, b
231230
* @param entry the {@link Entry} containing the {@link Properties property} edits
232231
*/
233232
public static boolean processString(Properties p, Entry entry) {
234-
var value = PropertyFileUtils.currentValue(p.getProperty(entry.getKey()), entry.getDefaultValue(),
235-
entry.getNewValue());
233+
var value = currentValue(p.getProperty(entry.getKey()), entry.getDefaultValue(), entry.getNewValue());
236234

237235
p.setProperty(entry.getKey(), String.valueOf(value));
238236

0 commit comments

Comments
 (0)