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.2 KiB

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