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.

echo.html 6.1 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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>Echo Task</title>
  20. </head>
  21. <body>
  22. <h2><a name="echo">Echo</a></h2>
  23. <h3>Description</h3>
  24. <p>Echoes a message to the current loggers and listeners which
  25. means <tt>System.out</tt> unless overridden. A <tt>level</tt>
  26. can be specified, which controls at what logging level the message is
  27. filtered at.
  28. <p>
  29. The task can also echo to a file, in which case the option to append rather
  30. than overwrite the file is available, and the <tt>level</tt> option is
  31. ignored</p>
  32. <h3>Parameters</h3>
  33. <table border="1" cellpadding="2" cellspacing="0">
  34. <tr>
  35. <td valign="top"><b>Attribute</b></td>
  36. <td valign="top"><b>Description</b></td>
  37. <td align="center" valign="top"><b>Required</b></td>
  38. </tr>
  39. <tr>
  40. <td valign="top">message</td>
  41. <td valign="top">the message to echo.</td>
  42. <td valign="top" align="center">No. Text may also be included in a
  43. character section within this element. If neither is included a
  44. blank line will be emitted in the output.</td>
  45. </tr>
  46. <tr>
  47. <td valign="top">file</td>
  48. <td valign="top">the file to write the message to.</td>
  49. <td valign="top" align="center" rowspan="2">Optionally one of these may be specified.</td>
  50. </tr>
  51. <tr>
  52. <td valign="top">output</td>
  53. <td valign="top">the <a href="../CoreTypes/resources.html">Resource</a>
  54. to write the message to (see <a href="../develop.html#set-magic">note</a>).
  55. <b>Since Ant 1.8</b></td>
  56. </tr>
  57. <tr>
  58. <td valign="top">append</td>
  59. <td valign="top">Append to an existing file (or
  60. <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/io/FileWriter.html#FileWriter(java.lang.String, boolean)" target="_blank">
  61. open a new file / overwrite an existing file</a>)? Default <i>false</i>.
  62. </td>
  63. <td valign="top" align="center">No; ignored unless <i>output</i> indicates a
  64. filesystem destination.</td>
  65. </tr>
  66. <tr>
  67. <td valign="top">level</td>
  68. <td valign="top">Control the level at which this message is reported.
  69. One of "error", "warning", "info", "verbose", "debug" (decreasing order)</td>
  70. <td valign="top" align="center">No - default is "warning".</td>
  71. </tr>
  72. <tr>
  73. <td valign="top">encoding</td>
  74. <td valign="top">encoding to use, default is ""; the local system encoding. <em>since Ant 1.7</em></td>
  75. <td valign="top" align="center">No</td>
  76. </tr>
  77. </table>
  78. <h3>Examples</h3>
  79. <pre>
  80. &lt;echo message=&quot;Hello, world&quot;/&gt;
  81. </pre>
  82. <pre>
  83. &lt;echo message=&quot;Embed a line break:${line.separator}&quot;/&gt;
  84. </pre>
  85. <pre>
  86. &lt;echo&gt;Embed another:${line.separator}&lt;/echo&gt;
  87. </pre>
  88. <pre>
  89. &lt;echo&gt;This is a longer message stretching over
  90. two lines.
  91. &lt;/echo&gt;
  92. </pre>
  93. <pre>
  94. &lt;echo&gt;
  95. This is a longer message stretching over
  96. three lines; the first line is a blank
  97. &lt;/echo&gt;
  98. </pre>
  99. The newline immediately following the &lt;echo&gt; tag will be part of the output.<br>
  100. Newlines in character data within the content of an element are not discarded by XML parsers.<br>
  101. See <a href="http://www.w3.org/TR/2004/REC-xml-20040204/#sec-line-ends">
  102. W3C Recommendation 04 February 2004 / End of Line handling
  103. </a> for more details.
  104. <pre>&lt;echo message=&quot;Deleting drive C:&quot; level=&quot;debug&quot;/&gt;</pre>
  105. A message which only appears in <tt>-debug</tt> mode.
  106. <pre>&lt;echo level=&quot;error&quot;&gt;
  107. Imminent failure in the antimatter containment facility.
  108. Please withdraw to safe location at least 50km away.
  109. &lt;/echo&gt;
  110. </pre>
  111. A message which appears even in <tt>-quiet</tt> mode.
  112. <pre>&lt;echo file="runner.csh" append="false"&gt;#\!/bin/tcsh
  113. java-1.3.1 -mx1024m ${project.entrypoint} $$*
  114. &lt;/echo&gt;</pre>
  115. Generate a shell script by echoing to a file.
  116. Note the use of a double $ symbol to stop Ant
  117. filtering out the single $ during variable expansion
  118. <p>Depending on the loglevel Ant runs, messages are print out or silently
  119. ignored:
  120. <table>
  121. <tr>
  122. <th>Ant-Statement</th>
  123. <th>-quiet, -q</th>
  124. <th><i>no statement</th>
  125. <th>-verbose, -v</th>
  126. <th>-debug, -d</th>
  127. </tr>
  128. <tr>
  129. <td><pre>&lt;echo message="This is error message." level="error" /&gt;</pre></td>
  130. <td align="center">ok</td>
  131. <td align="center">ok</td>
  132. <td align="center">ok</td>
  133. <td align="center">ok</td>
  134. </tr>
  135. <tr>
  136. <td><pre>&lt;echo message="This is warning message." /&gt;</pre></td>
  137. <td align="center">ok</td>
  138. <td align="center">ok</td>
  139. <td align="center">ok</td>
  140. <td align="center">ok</td>
  141. </tr>
  142. <tr>
  143. <td><pre>&lt;echo message="This is warning message." level="warning" /&gt;</pre></td>
  144. <td align="center">ok</td>
  145. <td align="center">ok</td>
  146. <td align="center">ok</td>
  147. <td align="center">ok</td>
  148. </tr>
  149. <tr>
  150. <td><pre>&lt;echo message="This is info message." level="info" /&gt;</pre></td>
  151. <td align="center">not logged</td>
  152. <td align="center">ok</td>
  153. <td align="center">ok</td>
  154. <td align="center">ok</td>
  155. </tr>
  156. <tr>
  157. <td><pre>&lt;echo message="This is verbose message." level="verbose" /&gt;</pre></td>
  158. <td align="center">not logged</td>
  159. <td align="center">not logged</td>
  160. <td align="center">ok</td>
  161. <td align="center">ok</td>
  162. </tr>
  163. <tr>
  164. <td><pre>&lt;echo message="This is debug message." level="debug" /&gt;</pre></td>
  165. <td align="center">not logged</td>
  166. <td align="center">not logged</td>
  167. <td align="center">not logged</td>
  168. <td align="center">ok</td>
  169. </tr>
  170. </table>
  171. </body>
  172. </html>