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.

loadproperties.html 4.1 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <!--
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. -->
  15. <html>
  16. <head>
  17. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  18. <title>LoadProperties Task</title>
  19. </head>
  20. <body>
  21. <h2 id="loadproperties">LoadProperties</h2>
  22. <h3>Description</h3>
  23. <p>Load a file's contents as Apache Ant properties. This is equivalent to <code>&lt;property
  24. file|resource=<q>...</q>/&gt;</code> except that it supports nested <code>&lt;filterchain&gt;</code>
  25. elements. Also if the file is missing, the build is halted with an error, rather than a warning
  26. being printed.</p>
  27. <p><strong>Note</strong>: the default value of this task's <var>prefixValues</var> attribute is
  28. different from the default value of the same attribute in
  29. the <a href="property.html"><code>&lt;property&gt;</code></a> task.</p>
  30. <h3>Parameters</h3>
  31. <table class="attr">
  32. <tr>
  33. <th>Attribute</th>
  34. <th>Description</th>
  35. <th>Required</th>
  36. </tr>
  37. <tr>
  38. <td>srcFile</td>
  39. <td>source file</td>
  40. <td rowspan="2">One of these or a nested resource</td>
  41. </tr>
  42. <tr>
  43. <td>resource</td>
  44. <td class="left">the resource name of the property file</td>
  45. </tr>
  46. <tr>
  47. <td>encoding</td>
  48. <td>encoding to use when loading the file</td>
  49. <td>No</td>
  50. </tr>
  51. <tr>
  52. <td>classpath</td>
  53. <td>the classpath to use when looking up a resource.</td>
  54. <td>No</td>
  55. </tr>
  56. <tr>
  57. <td>classpathref</td>
  58. <td>the classpath to use when looking up a resource, given
  59. as <a href="../using.html#references">reference</a> to a <code>&lt;path&gt;</code> defined
  60. elsewhere.</td>
  61. <td>No</td>
  62. </tr>
  63. <tr>
  64. <td>prefix</td>
  65. <td>Prefix to apply to loaded properties. <em>Since Ant 1.8.1</em></td>
  66. <td>No; default is <q>.</q></td>
  67. </tr>
  68. <tr>
  69. <td>prefixValues</td>
  70. <td>Whether to apply the prefix when expanding the right hand side of the properties. <em>Since
  71. Ant 1.8.2</em></td>
  72. <td>No; default is <q>true</q></td>
  73. </tr>
  74. </table>
  75. <h3>Parameters specified as nested elements</h3>
  76. <h4>any <a href="../Types/resources.html">resource</a> or single element
  77. resource collection</h4>
  78. <p><em>Since Ant 1.7</em></p>
  79. <p>The specified resource will be used as <var>srcFile</var> or <var>resource</var>.</p>
  80. <h4><a href="../Types/filterchain.html">FilterChain</a></h4>
  81. <h4>classpath</h4>
  82. <p>for use with the <var>resource</var> attribute.</p>
  83. <h3>Examples</h3>
  84. <pre>&lt;loadproperties srcFile="file.properties"/&gt;</pre>
  85. <p>or</p>
  86. <pre>
  87. &lt;loadproperties&gt;
  88. &lt;file file="file.properties"/&gt;
  89. &lt;/loadproperties&gt;</pre>
  90. <p>Load contents of file.properties as Ant properties.</p>
  91. <pre>
  92. &lt;loadproperties srcFile="file.properties"&gt;
  93. &lt;filterchain&gt;
  94. &lt;<a href="../Types/filterchain.html#linecontains">linecontains</a>&gt;
  95. &lt;contains value=&quot;import.&quot;/&gt;
  96. &lt;/linecontains&gt;
  97. &lt;/filterchain&gt;
  98. &lt;/loadproperties&gt;</pre>
  99. <p>Read the lines that contain the string <q>import.</q> from the file <samp>file.properties</samp>
  100. and load them as Ant properties.</p>
  101. <pre>
  102. &lt;loadproperties&gt;
  103. &lt;<a href="../Types/resources.html#gzipresource">gzipresource</a>&gt;
  104. &lt;<a href="../Types/resources.html#url">url</a> url="http://example.org/url.properties.gz"/&gt;
  105. &lt;/gzipresource&gt;
  106. &lt;/loadproperties&gt;</pre>
  107. <p>Load contents of <samp>http://example.org/url.properties.gz</samp>, uncompress it on the fly and
  108. load the contents as Ant properties.</p>
  109. </body>
  110. </html>