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.

echoproperties.html 4.4 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. http://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>Echoproperties Task</title>
  20. </head>
  21. <body>
  22. <h2 id="echoproperties">echoproperties</h2>
  23. <h3>Description</h3>
  24. <p>Displays all the current properties (or a subset of them specified by a
  25. nested <code>&lt;propertyset&gt;</code>) in the project. The output can be sent to a file if
  26. desired. This task can be used as a somewhat contrived means of returning data from an
  27. <kbd>ant</kbd> invocation, but is really for debugging build
  28. files.</p>
  29. <h3>Parameters</h3>
  30. <table class="attr">
  31. <tr>
  32. <th scope="col">Attribute</th>
  33. <th scope="col">Description</th>
  34. <th scope="col">Required</th>
  35. </tr>
  36. <tr>
  37. <td>destfile</td>
  38. <td>If specified, the value indicates the name of the file to send the output of the statement
  39. to. The generated output file is compatible for loading by any Java application as a property
  40. file.</td>
  41. <td>No; by default, output to the log</td>
  42. </tr>
  43. <tr>
  44. <td>prefix</td>
  45. <td>a prefix which is used to filter the properties: only properties whose names start with this
  46. prefix will be echoed.</td>
  47. <td>No</td>
  48. </tr>
  49. <tr>
  50. <td>regex</td>
  51. <td>a regular expression which is used to filter the properties: only those properties whose
  52. names match it will be echoed.</td>
  53. <td>No</td>
  54. </tr>
  55. <tr>
  56. <td>failonerror</td>
  57. <td>If an error occurs while writing the properties to a file, and this attribute is enabled,
  58. then a <code>BuildException</code> will be thrown, causing the build to fail. If disabled,
  59. then IO errors will be reported as a log statement, and the build will continue without
  60. failure from this task.</td>
  61. <td>No; default is <q>true</q></td>
  62. </tr>
  63. <tr>
  64. <td>format</td>
  65. <td>One of <q>text</q> or <q>xml</q>. Determines the output format.</td>
  66. <td>No; defaults to <q>text</q></td>
  67. </tr>
  68. </table>
  69. <h3>Parameters specified as nested elements</h3>
  70. <h4>propertyset</h4>
  71. <p><em>Since Ant 1.6</em>.</p>
  72. <p>You can specify subsets of properties to be echoed
  73. with <a href="../Types/propertyset.html">propertyset</a>s. Using <code>propertyset</code>s gives
  74. more control on which properties will be picked up. The attributes <var>prefix</var>
  75. and <var>regex</var> are just shortcuts that use <code>propertyset</code>s internally.</p>
  76. <h3>Examples</h3>
  77. <p>Report the current properties to the log.</p>
  78. <pre>&lt;echoproperties/&gt;</pre>
  79. <p>Report the current properties to the file <samp>my.properties</samp>, and fail the build if the
  80. file could not be created or written to.</p>
  81. <pre>&lt;echoproperties destfile="my.properties"/&gt;</pre>
  82. <p>Report the current properties to the file <samp>my.properties</samp>, and log a message if the
  83. file could not be created or written to, but still allow the build to continue.</p>
  84. <pre>&lt;echoproperties destfile="my.properties" failonerror="false"/&gt;</pre>
  85. <p>List all properties beginning with <samp>java.</samp></p>
  86. <pre>&lt;echoproperties prefix="java."/&gt;</pre>
  87. <p>Lists all properties beginning with <samp>java.</samp> using a
  88. nested <code>&lt;propertyset/&gt;</code> which is an equivalent but longer way.</p>
  89. <pre>
  90. &lt;echoproperties&gt;
  91. &lt;propertyset&gt;
  92. &lt;propertyref prefix="java."/&gt;
  93. &lt;/propertyset&gt;
  94. &lt;/echoproperties&gt;</pre>
  95. <p>Lists all properties that contain <samp>ant</samp> in their names.</p>
  96. <pre>&lt;echoproperties regex=".*ant.*"/&gt;</pre>
  97. <p>The equivalent snippet with <code>&lt;propertyset/&gt;</code> is:</p>
  98. <pre>
  99. &lt;echoproperties&gt;
  100. &lt;propertyset&gt;
  101. &lt;propertyref regex=".*ant.*"/&gt;
  102. &lt;/propertyset&gt;
  103. &lt;/echoproperties&gt;</pre>
  104. </body>
  105. </html>