bld Extension to Create or Modify Properties Files http://github.com/rife2/bld-property-file
Find a file
2024-06-22 23:39:49 -07:00
.github/workflows Bumped bld to version 1.9.1 2024-05-09 21:25:04 -07:00
.idea Bumped bld to version 1.9.1 2024-05-09 21:25:04 -07:00
.vscode Bumped bld to version 1.9.1 2024-05-09 21:25:04 -07:00
config Bumped PMD extension to version 0.9.9 2024-05-09 21:26:23 -07:00
examples Bumped PMD extension to version 1.1.0 2024-06-22 23:39:49 -07:00
lib/bld Bumped PMD extension to version 1.1.0 2024-06-22 23:39:49 -07:00
src Bumped to version 0.9.6-SNAPSHOT 2024-05-09 21:27:55 -07:00
.gitignore Added calc and modify functions 2023-04-04 09:01:12 -07:00
bld Updated to RIFE2 1.5.14 2023-04-03 02:20:09 -07:00
bld.bat Updated to RIFE2 1.5.14 2023-04-03 02:20:09 -07:00
LICENSE.txt Initial commit 2023-04-02 15:29:27 -07:00
README.md Bumped bld to version 1.9.1 2024-05-09 21:25:04 -07:00

bld Extension to Create or Modify Properties Files

License Java bld Release Snapshot GitHub CI

To install, please refer to the extensions documentation.

To create or modifying 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=0

Invoking 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=0

Property File

The 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

Entry

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())
set() The value to set the property to, regardless of its previous value.

EntryDate

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.
  • set or now are required.

Units

The following Units are available:

  • Units.MILLISECOND
  • Units.SECOND
  • Units.MINUTE
  • Units.HOUR
  • Units.DAY
  • Units.WEEK
  • Units.MONTH
  • Units.YEAR

EntryInt

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.