- Notifications
You must be signed in to change notification settings - Fork0
bld Extension to Create or Modify Properties Files
License
rife2/bld-property-file
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
bld Extension to Create or Modify Properties Files
To install the latest version, add the following to thelib/bld/bld-wrapper.properties
file:
bld.extension-property-file=com.uwyn.rife2:bld-property-file
For more information, please refer to theextensions documentation.
To create or modifyproperty files withbld, add the follwing to your build file:
@BuildCommandpublicvoidupdateMajor()throwsException {newPropertyFileOperation() .fromProject(this) .file("version.properties") .entry(newEntryInt("version.major").defaultValue(0).calc(ADD)) .entry(newEntryInt("version.minor").set(0)) .entry(newEntryInt("version.patch").set(0)) .entry(newEntryDate("build.date").now().pattern("yyyy-MM-dd")) .execute();}
Invoking theupdateMajor
command, will create theversion.propertees
file:
./bld updateMajor ...
# version.propertiesbuild.date=2023-04-02version.major=1version.minor=0version.patch=0
Invoking theupdateMajor
command again, will increase theversion.major
property:
./bld updateMajor ...
# version.propertiesbuild.date=2023-04-02version.major=2version.minor=0version.patch=0
ThePropertyFileOperation class is used to configure theproperties 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 totrue , will cause execution to fail on any warnings. | No |
TheEntry class is used to specify modifications to aString 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 aFormatter pattern. |
set() | The value to set the property to, regardless of its previous value. |
TheEntryDate class is used to specify modifications to adate 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 aDateTimeFormatter pattern. |
set() | TheCalendar,Date, orjava.time value to set the property to, regardless of its previous value. |
unit() | The unit to be used calculations. SeeUnits. |
set
ornow
are required.
The followingUnits are available:
Units.MILLISECOND
Units.SECOND
Units.MINUTE
Units.HOUR
Units.DAY
Units.WEEK
Units.MONTH
Units.YEAR
TheEntryInt class is used to specify modifications to ainteger 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 aDecimalFormat pattern. |
set() | Theinteger value to set the property to, regardless of its previous value. |
It is inspired by theant PropertyFile task.
About
bld Extension to Create or Modify Properties Files