Ant PropertyFile Task User Manual

by

Version 1.0 - 2000/11/02


Table of Contents


Introduction

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

Parameters

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

Entry

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

Examples

The following changes the my.properties file. Assume my.properties 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="my.properties" comment"My properties" > <entry key="akey" value="avalue" /> <entry key="adate" type="date" operation="now"/> <entry key="anint" type="int" operation="+"/> </propertyfile>