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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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 id="echo">Echo</h2>
  23. <h3>Description</h3>
  24. <p>Echoes a message to the current loggers and listeners which means <code>System.out</code> unless
  25. overridden. A <var>level</var> can be specified, which controls at what logging level the message is
  26. filtered at.</p>
  27. <p>The task can also echo to a file, in which case the option to append rather than overwrite the
  28. file is available, and the <var>level</var> option is ignored</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>message</td>
  38. <td>the message to echo.</td>
  39. <td>No; defaults to a blank line unless text is included in a character section within this
  40. element</td>
  41. </tr>
  42. <tr>
  43. <td>file</td>
  44. <td>the file to write the message to.</td>
  45. <td rowspan="2">No; only one of these may be used</td>
  46. </tr>
  47. <tr>
  48. <td>output</td>
  49. <td class="left">the <a href="../Types/resources.html">Resource</a>
  50. to write the message to (see <a href="../develop.html#set-magic">note</a>).
  51. <em>Since Apache Ant 1.8</em></td>
  52. </tr>
  53. <tr>
  54. <td>append</td>
  55. <td>Append to an existing file
  56. (or <a href="https://docs.oracle.com/javase/8/docs/api//java/io/FileWriter.html#FileWriter-java.lang.String-boolean-"
  57. target="_top"> open a new file / overwrite an existing file</a>)?
  58. </td>
  59. <td>No; ignored unless <var>output</var> indicates a filesystem destination, default
  60. is <q>false</q></td>
  61. </tr>
  62. <tr>
  63. <td>level</td>
  64. <td>Control the level at which this message is reported. One
  65. of <q>error</q>, <q>warning</q>, <q>info</q>, <q>verbose</q>, <q>debug</q> (decreasing
  66. order)</td>
  67. <td>No; default is <q>warning</q></td>
  68. </tr>
  69. <tr>
  70. <td>encoding</td>
  71. <td>encoding to use. <em>since Ant 1.7</em></td>
  72. <td>No; defaults to default JVM character encoding</td>
  73. </tr>
  74. <tr>
  75. <td>force</td>
  76. <td>Overwrite read-only destination files. <em>since Ant 1.8.2</em></td>
  77. <td>No; defaults to <q>false</q></td>
  78. </tr>
  79. </table>
  80. <h3>Examples</h3>
  81. <p>Basic use:</p>
  82. <pre>&lt;echo message=&quot;Hello, world&quot;/&gt;</pre>
  83. <pre>&lt;echo message=&quot;Embed a line break:${line.separator}&quot;/&gt;</pre>
  84. <pre>&lt;echo&gt;Embed another:${line.separator}&lt;/echo&gt;</pre>
  85. <pre>&lt;echo&gt;This is a longer message stretching over
  86. two lines.
  87. &lt;/echo&gt;</pre>
  88. <p>The newline immediately following the <code>&lt;echo&gt;</code> tag is part of the
  89. output. Newlines in character data within the content of an element are not discarded by XML
  90. parsers.<br/>See <a href="https://www.w3.org/TR/xml/#sec-line-ends" target="_top">W3C Recommendation
  91. 26 November 2008 / End of Line handling</a> for more details.</p>
  92. <pre>&lt;echo&gt;
  93. This is a longer message stretching over
  94. three lines; the first line is a blank
  95. &lt;/echo&gt;</pre>
  96. <p>A message which only appears in <kbd>-debug</kbd> mode.</p>
  97. <pre>&lt;echo message=&quot;Deleting drive C:&quot; level=&quot;debug&quot;/&gt;</pre>
  98. <p>A message which appears even in <kbd>-quiet</kbd> mode.</p>
  99. <pre>&lt;echo level=&quot;error&quot;&gt;
  100. Imminent failure in the antimatter containment facility.
  101. Please withdraw to safe location at least 50km away.
  102. &lt;/echo&gt;</pre>
  103. <p>Generate a shell script by echoing to a file. Note the use of a double <q>$</q> symbol to stop
  104. Ant filtering out the single <q>$</q> during variable expansion.</p>
  105. <pre>&lt;echo file="runner.csh" append="false"&gt;#\!/bin/tcsh
  106. java-1.3.1 -mx1024m ${project.entrypoint} $$*
  107. &lt;/echo&gt;</pre>
  108. <p>Depending on the log level Ant runs at, messages are print out or silently ignored:</p>
  109. <table>
  110. <tr>
  111. <th scope="col">Ant command line</th>
  112. <th scope="col"><kbd>-quiet</kbd>, <kbd>-q</kbd></th>
  113. <th scope="col"><em>no switch</em></th>
  114. <th scope="col"><kbd>-verbose</kbd>, <kbd>-v</kbd></th>
  115. <th scope="col"><kbd>-debug</kbd>, <kbd>-d</kbd></th>
  116. </tr>
  117. <tr>
  118. <td><pre>&lt;echo message="This is error message." level="error"/&gt;</pre></td>
  119. <td>ok</td>
  120. <td>ok</td>
  121. <td>ok</td>
  122. <td>ok</td>
  123. </tr>
  124. <tr>
  125. <td><pre>&lt;echo message="This is warning message."/&gt;</pre></td>
  126. <td>ok</td>
  127. <td>ok</td>
  128. <td>ok</td>
  129. <td>ok</td>
  130. </tr>
  131. <tr>
  132. <td><pre>&lt;echo message="This is warning message." level="warning"/&gt;</pre></td>
  133. <td>ok</td>
  134. <td>ok</td>
  135. <td>ok</td>
  136. <td>ok</td>
  137. </tr>
  138. <tr>
  139. <td><pre>&lt;echo message="This is info message." level="info"/&gt;</pre></td>
  140. <td>not logged</td>
  141. <td>ok</td>
  142. <td>ok</td>
  143. <td>ok</td>
  144. </tr>
  145. <tr>
  146. <td><pre>&lt;echo message="This is verbose message." level="verbose"/&gt;</pre></td>
  147. <td>not logged</td>
  148. <td>not logged</td>
  149. <td>ok</td>
  150. <td>ok</td>
  151. </tr>
  152. <tr>
  153. <td><pre>&lt;echo message="This is debug message." level="debug"/&gt;</pre></td>
  154. <td>not logged</td>
  155. <td>not logged</td>
  156. <td>not logged</td>
  157. <td>ok</td>
  158. </tr>
  159. </table>
  160. </body>
  161. </html>