You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

propertyfile.html 5.4 kB

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