~ubuntu-branches/ubuntu/jaunty/ant/jaunty-proposed

« back to all changes in this revision

Viewing changes to docs/manual/OptionalTasks/propertyfile.html

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Gybas
  • Date: 2002-02-14 14:28:48 UTC
  • Revision ID: james.westby@ubuntu.com-20020214142848-2ww7ynmqkj31vlmn
Tags: upstream-1.4.1
ImportĀ upstreamĀ versionĀ 1.4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<html>
 
2
<head>
 
3
<meta http-equiv="Content-Language" content="en-us">
 
4
<title>Ant PropertyFile Task</title>
 
5
 
 
6
</head>
 
7
 
 
8
<body>
 
9
 
 
10
<h1>Ant PropertyFile Task User Manual</h1>
 
11
<p>by</p>
 
12
<!-- Names are in alphabetical order, on last name -->
 
13
<ul>
 
14
  <li>Thomas Christen (<a href="mailto:chr@active.ch">chr@active.ch</a>)</li>
 
15
  <li>Jeremy Mawson (<a href="mailto:jem@loftinspace.com.au">jem@loftinspace.com/au</a>)</li>
 
16
</ul>
 
17
 
 
18
<p>Version 1.1 - 2001/01/28</p>
 
19
<hr>
 
20
<h2>Table of Contents</h2>
 
21
<ul>
 
22
  <li><a href="#introduction">Introduction</a></li>
 
23
  <li><a href="#proptask">PropertyFile Task</a></li>
 
24
  <li><a href="#entryElement">Entry Task</a></li>
 
25
</ul>
 
26
 
 
27
<hr>
 
28
<h2><a name="introduction">Introduction</a></h2>
 
29
<p>Ant provides an optional task for editing property files.  This is very useful
 
30
when wanting to make unattended modifications to configuration files for application
 
31
servers and applications.  Currently, the task maintains a working property file with
 
32
the ability to add properties or make changes to existing ones.  However, any comments
 
33
are lost.  Work is being done to make this task a bit more &quot;human friendly&quot;.</p>
 
34
 
 
35
<hr>
 
36
<h2><a name="proptask">PropertyFile Task</a></h2>
 
37
<h3>Parameters</h3>
 
38
<table border="1" cellpadding="2" cellspacing="0">
 
39
<tr>
 
40
  <td width="12%" valign="top"><b>Attribute</b></td>
 
41
  <td width="78%" valign="top"><b>Description</b></td>
 
42
  <td width="10%" valign="top"><b>Required</b></td>
 
43
</tr>
 
44
<tr>
 
45
  <td width="12%" valign="top">file</td>
 
46
  <td width="78%" valign="top">Location of the property file to be edited</td>
 
47
  <td width="10%" valign="top">Yes</td>
 
48
</tr>
 
49
<tr>
 
50
  <td width="12%" valign="top">comment</td>
 
51
  <td width="78%" valign="top">Header for the file itself</td>
 
52
  <td width="10%" valign="top">no</td>
 
53
</tr>
 
54
</table>
 
55
 
 
56
<h3>Parameters specified as nested elements</h3>
 
57
<h4><a name="entryElement">Entry</a></h4>
 
58
<p>Use nested <code>&lt;entry&gt;</code>
 
59
elements to specify actual modifcations to the property file itself</p>
 
60
<table border="1" cellpadding="2" cellspacing="0">
 
61
  <tr>
 
62
    <td valign="top"><b>Attribute</b></td>
 
63
    <td valign="top"><b>Description</b></td>
 
64
    <td align="center" valign="top"><b>Required</b></td>
 
65
  </tr>
 
66
  <tr>
 
67
    <td valign="top">key</td>
 
68
    <td valign="top">Name of the property name/value pair</td>
 
69
    <td valign="top" align="center">Yes</td>
 
70
  </tr>
 
71
  <tr>
 
72
    <td valign="top">value</td>
 
73
    <td valign="top">Value to set (=), to add (+) or subtract (-)</td>
 
74
    <td valign="top" align="center">Yes</td>
 
75
  </tr>
 
76
  <tr>
 
77
    <td valign="top">type</td>
 
78
    <td valign="top">Regard the value as : int, date or string (default)</td>
 
79
    <td valign="top" align="center">No</td>
 
80
  </tr>
 
81
  <tr>
 
82
    <td valign="top">operation</td>
 
83
    <td valign="top">&quot;+&quot; or &quot;=&quot; (default) for all datatypes<br>&quot;-&quot; (for date and int only).<br>
 
84
    </td>
 
85
    <td valign="top" align="center">No</td>
 
86
  </tr>
 
87
  <tr>
 
88
    <td valign="top">default</td>
 
89
    <td valign="top">Initial value to set for a property if it is not
 
90
                     already defined in the property file.<br>
 
91
                     For type date, two additional keywords are allowed: &quot;now&quot; or &quot;never&quot;.</td>
 
92
    <td valign="top" align="center">No</td>
 
93
  </tr>
 
94
  <tr>
 
95
    <td valign="top">pattern</td>
 
96
    <td valign="top">For int and date type only. If present, Values will
 
97
                     be parsed and formatted accordingly.</td>
 
98
    <td valign="top" align="center">No</td>
 
99
  </tr>
 
100
</table>
 
101
<h3>Examples</h3>
 
102
 
 
103
<p>The following changes the my.properties file.  Assume my.properties look like:</p>
 
104
 
 
105
<pre># A comment
 
106
akey=novalue</pre>
 
107
 
 
108
<p>After running, the file would now look like
 
109
</p>
 
110
<pre>#Thu Nov 02 23:41:47 EST 2000
 
111
akey=avalue
 
112
adate=2000/11/02 23\:41
 
113
anint=1
 
114
formated.int=0014
 
115
formated.date=028 17\:34
 
116
</pre>
 
117
<p>
 
118
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.
 
119
</p>
 
120
 
 
121
<blockquote><pre>&lt;propertyfile
 
122
    file=&quot;my.properties&quot;
 
123
    comment&quot;My properties&quot; &gt;
 
124
  &lt;entry  key=&quot;akey&quot; value=&quot;avalue&quot; /&gt;
 
125
  &lt;entry  key=&quot;adate&quot; type=&quot;date&quot; value=&quot;now&quot;/&gt;
 
126
  &lt;entry  key=&quot;anint&quot; type=&quot;int&quot; operation=&quot;+&quot;/&gt;
 
127
  &lt;entry  key=&quot;formated.int&quot; type=&quot;int&quot; default=&quot;0013&quot; operation=&quot;+&quot; pattern=&quot;0000&quot;/&gt;
 
128
  &lt;entry  key=&quot;formated.date&quot; type=&quot;date&quot; value=&quot;now&quot; pattern=&quot;DDD HH:mm&quot;/&gt;
 
129
&lt;/propertyfile&gt;
 
130
</pre></blockquote>
 
131
<p>
 
132
To produce dates relative from today :</p>
 
133
<blockquote><pre>&lt;propertyfile
 
134
    file=&quot;my.properties&quot;
 
135
    comment=&quot;My properties&quot; &gt;
 
136
  &lt;entry  key=&quot;formated.date-1&quot;
 
137
      type=&quot;date&quot; default=&quot;now&quot; pattern=&quot;DDD&quot;
 
138
      operation=&quot;-&quot; value=&quot;1&quot;/&gt;
 
139
  &lt;entry  key=&quot;formated.tomorrow&quot;
 
140
      type=&quot;date&quot; default=&quot;now&quot; pattern=&quot;DDD&quot;
 
141
      operation=&quot;+&quot; value=&quot;1&quot;/&gt;
 
142
&lt;/propertyfile&gt;
 
143
</pre></blockquote>
 
144
 
 
145
<p>
 
146
Concatenation of strings :</p>
 
147
<blockquote><pre>&lt;propertyfile
 
148
    file=&quot;my.properties&quot;
 
149
    comment=&quot;My properties&quot; &gt;
 
150
  &lt;entry  key=&quot;progress&quot; default=&quot;&quot; operation=&quot;+&quot; value=&quot;.&quot;/&gt;
 
151
&lt;/propertyfile&gt;
 
152
</pre></blockquote>
 
153
<p>Each time called, a &quot;.&quot; will be appended to &quot;progress&quot;
 
154
</p>
 
155
</body>
 
156
</html>