bld Extension to Create or Modify Properties Files
To install the latest version, add the following to the lib/bld/bld-wrapper.properties file:
bld.extension-property-file=com.uwyn.rife2:bld-property-fileFor more information, please refer to the extensions documentation.
To create or modify property files with bld, add the follwing to your build file:
@BuildCommand
public void updateMajor() throws Exception {
new PropertyFileOperation()
.fromProject(this)
.file("version.properties")
.entry(new EntryInt("version.major").defaultValue(0).calc(ADD))
.entry(new EntryInt("version.minor").set(0))
.entry(new EntryInt("version.patch").set(0))
.entry(new EntryDate("build.date").now().pattern("yyyy-MM-dd"))
.execute();
}Invoking the updateMajor command, will create the version.properteesfile:
./bld updateMajor ...# version.properties
build.date=2023-04-02
version.major=1
version.minor=0
version.patch=0Invoking the updateMajor command again, will increase the version.major property:
./bld updateMajor ...# version.properties
build.date=2023-04-02
version.major=2
version.minor=0
version.patch=0The PropertyFileOperation class is used to configure the properties file location, etc.
| Function | Description | Required |
|---|---|---|
file() |
The location of the properties files to modify. | Yes |
comment() |
Comment to be inserted at the top of the properties file. | No |
failOnWarning() |
If set to true, will cause execution to fail on any warnings. |
No |
The Entry class is used to specify modifications to a String property.
| Function | Description/Example |
|---|---|
defaultValue() |
The value to be used if the property doesn't exist. |
delete() |
Delete the property. |
modify() |
modify("-foo", String::concat)modify("-foo", (v, s) -> v + s)modify((v, s) -> v.trim()) |
pattern() |
If present, will parse the value as a Formatter pattern. |
set() |
The value to set the property to, regardless of its previous value. |
The EntryDate class is used to specify modifications to a date property.
| Function | Description/Example |
|---|---|
calc() |
calc(ADD)calc(v -> v + 1)calc(SUB)calc(v -> v - 1) |
delete() |
Delete the property. |
now() |
Set the entry to the current date/time. |
pattern() |
If present, will parse the value as a DateTimeFormatter pattern. |
set() |
The Calendar, Date, or java.time value to set the property to, regardless of its previous value. |
unit() |
The unit to be used calculations. See Units. |
setornoware required.
The following Units are available:
Units.MILLISECONDUnits.SECONDUnits.MINUTEUnits.HOURUnits.DAYUnits.WEEKUnits.MONTHUnits.YEAR
The EntryInt class is used to specify modifications to a integer property.
| Function | Description/Example |
|---|---|
defaultValue() |
The value to be used if the property doesn't exist. |
calc() |
calc(ADD)calc(v -> v + 1)calc(SUB)calc(v -> v - 1) |
delete() |
Delete the property. |
pattern() |
If present, will parse the value as a DecimalFormat pattern. |
set() |
The integer value to set the property to, regardless of its previous value. |
It is inspired by the ant PropertyFile task.