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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. <meta http-equiv="Content-Language" content="en-us">
  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. <code>ant</code> invocation, but is really for debugging build
  28. files.</p>
  29. <h3>Parameters</h3>
  30. <table class="attr">
  31. <tr>
  32. <th>Attribute</th>
  33. <th>Description</th>
  34. <th>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 BuildException will be thrown, causing the build to fail. If disabled, then IO errors
  59. will be reported as a log statement, and the build will continue without failure from this
  60. 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>You can specify subsets of properties to be echoed
  72. with <a href="../Types/propertyset.html">propertyset</a>s. Using <code>propertyset</code>s gives
  73. more control on which properties will be picked up. The attributes <var>prefix</var>
  74. and <var>regex</var> are just shortcuts that use <code>propertyset</code>s internally.</p>
  75. <p><em>since Ant 1.6</em>.</p>
  76. <h3>Examples</h3>
  77. <pre>&lt;echoproperties/&gt;</pre>
  78. <p>Report the current properties to the log.</p>
  79. <pre>&lt;echoproperties destfile="my.properties"/&gt;</pre>
  80. <p>Report the current properties to the file <samp>my.properties</samp>, and will fail the build if
  81. the file could not be created or written to.</p>
  82. <pre>&lt;echoproperties destfile="my.properties" failonerror="false"/&gt;</pre>
  83. <p>Report the current properties to the file <samp>my.properties</samp>, and will log a message if
  84. the file could not be created or written to, but will still allow the build to continue.</p>
  85. <pre>&lt;echoproperties prefix="java."/&gt;</pre>
  86. <p>List all properties beginning with <samp>java.</samp></p>
  87. <pre>
  88. &lt;echoproperties&gt;
  89. &lt;propertyset&gt;
  90. &lt;propertyref prefix="java."/&gt;
  91. &lt;/propertyset&gt;
  92. &lt;/echoproperties&gt;</pre>
  93. <p>This again lists all properties beginning with <samp>java.</samp> using a
  94. nested <code>&lt;propertyset/&gt;</code> which is an equivalent but longer way.</p>
  95. <pre>&lt;echoproperties regex=".*ant.*"/&gt;</pre>
  96. <p>Lists all properties that contain <samp>ant</samp> in their names. The equivalent snippet
  97. 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>