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 3.4 KiB

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