by
Version 1.1 - 2001/01/28
Ant provides an optional task for editing property files. Thes is very useful when wanting to make unattended modifications to configuration files for application servers and applications. Currently, the task maintains a working property file with the ability to add properties or make changes to existing ones. However, any comments are lost. Work is being done to make this task a bit more "human friendly".
Attribute | Description | Required |
file | Location of the property file to be edited | Yes |
comment | Header for the file itself | no |
Use nested <entry>
elements to specify actual modifcations to the property file itself
Attribute | Description | Required |
key | Name of the property name/value pair | Yes |
value | Value to set (=), to add (+) or subtract (-) | Yes |
type | Regard the value as : int, date or string (default) | No |
operation | "+" or "=" (default) for all datatypes "-" (for date and int only). |
No |
default | Initial value to set for a property if it is not
already defined in the property file. For type date, two additional keywordsw are allowed: "now" or "never". |
No |
pattern | For int and date type only. If present, Values will be paresed and formated accordingly. | No |
The following changes the my.properties file. Assume my.properties look like:
<propertyfile file="my.properties" comment"My properties" > <entry key="akey" value="avalue" /> <entry key="adate" type="date" value="now"/> <entry key="anint" type="int" operation="+"/> <entry key="formated.int" type="int" default="0013" operation="+" pattern="0000"/> <entry key="formated.date" type="date" value="now" pattern="DDD HH:mm"/> </propertyfile>
To produce dates relative from today :
<propertyfile file="my.properties" comment"My properties" > <entry key="formated.date-1" type="date" default="now" pattern="DDD" operation="-" value="1"/> <entry key="formated.tomorrow" type="date" default="now" pattern="DDD" operation="+" value="1"/> </propertyfile>
Concatenation of strings :
Each time called, a "." will be appended to "progress"<propertyfile file="my.properties" comment"My properties" > <entry key="progress" default="" operation="+" value="."/> </propertyfile>