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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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><a name="loadproperties">LoadProperties</a></h2>
  22. <h3>Description</h3>
  23. <p>
  24. Load a file's contents as Ant properties. This is equivalent
  25. to <code>&lt;property file|resource=&quot;...&quot;/&gt;</code> except that it
  26. supports nested <code>&lt;filterchain&gt;</code> elements.
  27. Also if the file is missing, the build is halted with an error, rather
  28. than a warning being printed.
  29. </p>
  30. <p>If you want to simulate <a href="property.html">property</a>'s
  31. prefix attribute, please use <a
  32. href="../CoreTypes/filterchain.html#prefixlines">prefixlines</a>
  33. filter.</p>
  34. <h3>Parameters</h3>
  35. <table border="1" cellpadding="2" cellspacing="0">
  36. <tr>
  37. <td valign="top"><b>Attribute</b></td>
  38. <td valign="top"><b>Description</b></td>
  39. <td align="center" valign="top"><b>Required</b></td>
  40. </tr>
  41. <tr>
  42. <td valign="top">srcFile</td>
  43. <td valign="top">source file</td>
  44. <td valign="top" rowspan="2" align="center">One of these or a
  45. nested resource</td>
  46. </tr>
  47. <tr>
  48. <td valign="top">resource</td>
  49. <td valign="top">the resource name of the property file</td>
  50. </tr>
  51. <tr>
  52. <td valign="top">encoding</td>
  53. <td valign="top">encoding to use when loading the file</td>
  54. <td align="center" valign="top">No</td>
  55. </tr>
  56. <tr>
  57. <td valign="top">classpath</td>
  58. <td valign="top">the classpath to use when looking up a resource.</td>
  59. <td align="center" valign="top">No</td>
  60. </tr>
  61. <tr>
  62. <td valign="top">classpathref</td>
  63. <td valign="top">the classpath to use when looking up a resource,
  64. given as <a href="../using.html#references">reference</a>
  65. to a <code>&lt;path&gt;</code> defined elsewhere..</td>
  66. <td align="center" valign="top">No</td>
  67. </tr>
  68. </table>
  69. <h3>Parameters specified as nested elements</h3>
  70. <h4>any <a href="../CoreTypes/resources.html">resource</a> or single element
  71. resource collection</h4>
  72. <p>The specified resource will be used as src. <em>Since Ant 1.7</em></p>
  73. <h4><a href="../CoreTypes/filterchain.html">FilterChain</a></h4>
  74. <h4>classpath</h4>
  75. <p>for use with the <i>resource</i> attribute.</p>
  76. <h3>Examples</h3>
  77. <pre> &lt;loadproperties srcFile="file.properties"/&gt;
  78. </pre>
  79. or
  80. <pre>
  81. &lt;loadproperties&gt;
  82. &lt;file file="file.properties"/&gt;
  83. &lt;/loadproperties&gt;
  84. </pre>
  85. Load contents of file.properties as Ant properties.
  86. <pre> &lt;loadproperties srcFile="file.properties"&gt;
  87. &lt;filterchain&gt;
  88. &lt;<a href="../CoreTypes/filterchain.html#linecontains">linecontains</a>&gt;
  89. &lt;contains value=&quot;import.&quot;/&gt;
  90. &lt;/linecontains&gt;
  91. &lt;/filterchain&gt;
  92. &lt;/loadproperties&gt;
  93. </pre>
  94. Read the lines that contain the string &quot;import.&quot;
  95. from the file &quot;file.properties&quot; and load them as
  96. Ant properties.
  97. <pre>
  98. &lt;loadproperties&gt;
  99. &lt;<a href="../CoreTypes/resources.html#gzipresource">gzipresource</a>&gt;
  100. &lt;<a href="../CoreTypes/resources.html#url">url</a> url="http://example.org/url.properties.gz"/&gt;
  101. &lt;/gzipresource&gt;
  102. &lt;/loadproperties&gt;
  103. </pre>
  104. Load contents of http://example.org/url.properties.gz, uncompress it
  105. on the fly and load the contents as Ant properties.
  106. </body>
  107. </html>