Ant PropertyFile Task User Manual


Version 1.0 - 2000/11/02

Table of Contents


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

PropertyFile Task


Attribute Description Required
file Location of the property file to be edited Yes
comment Header for the file itself no

Parameters specified as nested elements


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 for the key the property name/value pair Yes
type Manipulate the value as type: int, date No, but must be used if opertion attribute used
operation If type is date, this cane be "now" or "never". If the type is int, only "-" and "+" may be used. No


The following changes the file. Assume look like:

After running, the file would now look like

The slashes conform to the expectations of the Properties class. The file will be stored in a manner so that each character is examined and escaped if necessary. Note that the original comment is now lost. Please keep this in mind when running this task against heavily commented properties files. It may be best to have a commented version in the source tree, copy it to a deployment area, and then run the modifications on the copy. Future versions of PropertyFile will hopefully eliminate this shortcoming.

<propertyfile file="" comment"My properties" > <entry key="akey" value="avalue" /> <entry key="adate" type="date" operation="now"/> <entry key="anint" type="int" operation="+"/> </propertyfile>