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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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><a name="echoproperties">echoproperties</a></h2>
  23. <h3>Description</h3>
  24. <p>Displays all the current properties (or a subset of them specified
  25. by a nested <code>&lt;propertyset&gt;</code>) in the project. The
  26. output can be sent to a file if desired. This task can be used as a
  27. somewhat contrived means of returning data from an
  28. <tt>&lt;ant&gt;</tt> invocation, but is really for debugging build
  29. files.</p>
  30. <h3>Parameters</h3>
  31. <table border="1" cellpadding="2" cellspacing="0">
  32. <tr>
  33. <td valign="top"><b>Attribute</b></td>
  34. <td valign="top"><b>Description</b></td>
  35. <td align="center" valign="top"><b>Required</b></td>
  36. </tr>
  37. <tr>
  38. <td valign="top">destfile</td>
  39. <td valign="top">If specified, the value indicates the name of the
  40. file to send the output of the statement to. The generated output file
  41. is compatible for loading by any Java application as a property file.
  42. If not specified, then the output will go to the Apache Ant log.</td>
  43. <td valign="top" align="center">No</td>
  44. </tr>
  45. <tr>
  46. <td valign="top">prefix</td>
  47. <td valign="top">
  48. a prefix which is used to filter the properties
  49. only those properties starting with this prefix will be echoed.
  50. <P>
  51. </td>
  52. <td valign="top" align="center">No</td>
  53. </tr>
  54. <tr>
  55. <td valign="top">regex</td>
  56. <td valign="top">
  57. a regular expression which is used to filter the
  58. properties
  59. only those properties whose names match it will be echoed.
  60. </td>
  61. <td valign="top" align="center">No</td>
  62. </tr>
  63. <tr>
  64. <td valign="top">failonerror</td>
  65. <td valign="top">By default, the "failonerror" attribute is enabled.
  66. If an error occurs while writing the properties to a file, and this
  67. attribute is enabled, then a BuildException will be thrown, causing the
  68. build to fail. If disabled, then IO errors will be reported as a log
  69. statement, and the build will continue without failure from this task.</td>
  70. <td valign="top" align="center">No</td>
  71. </tr>
  72. <tr>
  73. <td valign="top">format</td>
  74. <td valign="top">One of <code>text</code> or <code>xml</code>.
  75. Determines the output format. Defaults to <code>text</code>.</td>
  76. <td valign="top" align="center">No</td>
  77. </tr>
  78. </table>
  79. <h3>Parameters specified as nested elements</h3>
  80. <h4>propertyset</h4>
  81. <p>You can specify subsets of properties to be echoed with <a
  82. href="../Types/propertyset.html">propertyset</a>s. Using
  83. <tt>propertyset</tt>s gives more control on which properties will be
  84. picked up. The attributes <tt>prefix</tt> and <tt>regex</tt> are just
  85. shorcuts that use <tt>propertyset</tt>s internally.
  86. </p>
  87. <p><em>since Ant 1.6</em>.</p>
  88. <h3>Examples</h3>
  89. <blockquote><pre>
  90. &lt;echoproperties/&gt;
  91. </pre></blockquote>
  92. <p>Report the current properties to the log.</p>
  93. <blockquote><pre>
  94. &lt;echoproperties destfile="my.properties"/&gt;
  95. </pre></blockquote>
  96. <p>Report the current properties to the file "my.properties", and will
  97. fail the build if the file could not be created or written to.</p>
  98. <blockquote><pre>
  99. &lt;echoproperties destfile="my.properties" failonerror="false"/&gt;
  100. </pre></blockquote>
  101. <p>Report the current properties to the file "my.properties", and will
  102. log a message if the file could not be created or written to, but will still
  103. allow the build to continue.</p>
  104. <blockquote><pre>
  105. &lt;echoproperties prefix="java."/&gt;
  106. </pre></blockquote>
  107. <p>List all properties beginning with "java."</p>
  108. <blockquote><pre>
  109. &lt;echoproperties&gt;
  110. &lt;propertyset&gt;
  111. &lt;propertyref prefix="java."/&gt;
  112. &lt;/propertyset&gt;
  113. &lt;/echoproperties&gt;
  114. </pre></blockquote>
  115. <p>This again lists all properties beginning with "java." using a nested
  116. <tt>&lt;/propertyset&gt;</tt> which is an equivalent but longer way.</p>
  117. <blockquote><pre>
  118. &lt;echoproperties regex=".*ant.*"/&gt;
  119. </pre></blockquote>
  120. <p>Lists all properties that contain "ant" in their names.
  121. The equivalent snippet with <tt>&lt;/propertyset&gt;</tt> is:</p>
  122. <blockquote><pre>
  123. &lt;echoproperties&gt;
  124. &lt;propertyset&gt;
  125. &lt;propertyref regex=".*ant.*"/&gt;
  126. &lt;/propertyset&gt;
  127. &lt;/echoproperties&gt;
  128. </pre></blockquote>
  129. </body>
  130. </html>