Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

bld Extension to Create or Modify Properties Files

License

NotificationsYou must be signed in to change notification settings

rife2/bld-property-file

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

94 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bld Extension to Create or Modify Properties Files

LicenseJavabldReleaseSnapshotGitHub CI

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.

Create or Modify Property Files

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.properteesfile:

./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

Property File

ThePropertyFileOperation class is used to configure theproperties file location, etc.

FunctionDescriptionRequired
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

Entry

TheEntry class is used to specify modifications to aString property.

FunctionDescription/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.

EntryDate

TheEntryDate class is used to specify modifications to adate property.

FunctionDescription/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.

Units

The followingUnits are available:

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

EntryInt

TheEntryInt class is used to specify modifications to ainteger property.

FunctionDescription/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.


[8]ページ先頭

©2009-2025 Movatter.jp