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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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>Attribute</th>
  33. <th>Description</th>
  34. <th>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="_blank"> 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. <pre>&lt;echo message=&quot;Hello, world&quot;/&gt;</pre>
  82. <pre>&lt;echo message=&quot;Embed a line break:${line.separator}&quot;/&gt;</pre>
  83. <pre>&lt;echo&gt;Embed another:${line.separator}&lt;/echo&gt;</pre>
  84. <pre>&lt;echo&gt;This is a longer message stretching over
  85. two lines.
  86. &lt;/echo&gt;</pre>
  87. <pre>&lt;echo&gt;
  88. This is a longer message stretching over
  89. three lines; the first line is a blank
  90. &lt;/echo&gt;</pre>
  91. <p>The newline immediately following the <code>&lt;echo&gt;</code> tag will be part of the
  92. output. Newlines in character data within the content of an element are not discarded by XML
  93. parsers.<br/>See <a href="https://www.w3.org/TR/xml/#sec-line-ends">W3C Recommendation 26 November
  94. 2008 / End of Line handling</a> for more details.</p>
  95. <pre>&lt;echo message=&quot;Deleting drive C:&quot; level=&quot;debug&quot;/&gt;</pre>
  96. <p>A message which only appears in <code>-debug</code> mode.</p>
  97. <pre>&lt;echo level=&quot;error&quot;&gt;
  98. Imminent failure in the antimatter containment facility.
  99. Please withdraw to safe location at least 50km away.
  100. &lt;/echo&gt;</pre>
  101. <p>A message which appears even in <code>-quiet</code> mode.</p>
  102. <pre>&lt;echo file="runner.csh" append="false"&gt;#\!/bin/tcsh
  103. java-1.3.1 -mx1024m ${project.entrypoint} $$*
  104. &lt;/echo&gt;</pre>
  105. <p>Generate a shell script by echoing to a file. Note the use of a double <q>$</q> symbol to stop
  106. Ant filtering out the single <q>$</q> during variable expansion.</p>
  107. <p>Depending on the log level Ant runs at, messages are print out or silently ignored:</p>
  108. <table>
  109. <tr>
  110. <th>Ant command line</th>
  111. <th><code>-quiet</code>, <code>-q</code></th>
  112. <th><em>no switch</em></th>
  113. <th><code>-verbose</code>, <code>-v</code></th>
  114. <th><code>-debug</code>, <code>-d</code></th>
  115. </tr>
  116. <tr>
  117. <td><pre>&lt;echo message="This is error message." level="error"/&gt;</pre></td>
  118. <td>ok</td>
  119. <td>ok</td>
  120. <td>ok</td>
  121. <td>ok</td>
  122. </tr>
  123. <tr>
  124. <td><pre>&lt;echo message="This is warning message."/&gt;</pre></td>
  125. <td>ok</td>
  126. <td>ok</td>
  127. <td>ok</td>
  128. <td>ok</td>
  129. </tr>
  130. <tr>
  131. <td><pre>&lt;echo message="This is warning message." level="warning"/&gt;</pre></td>
  132. <td>ok</td>
  133. <td>ok</td>
  134. <td>ok</td>
  135. <td>ok</td>
  136. </tr>
  137. <tr>
  138. <td><pre>&lt;echo message="This is info message." level="info"/&gt;</pre></td>
  139. <td>not logged</td>
  140. <td>ok</td>
  141. <td>ok</td>
  142. <td>ok</td>
  143. </tr>
  144. <tr>
  145. <td><pre>&lt;echo message="This is verbose message." level="verbose"/&gt;</pre></td>
  146. <td>not logged</td>
  147. <td>not logged</td>
  148. <td>ok</td>
  149. <td>ok</td>
  150. </tr>
  151. <tr>
  152. <td><pre>&lt;echo message="This is debug message." level="debug"/&gt;</pre></td>
  153. <td>not logged</td>
  154. <td>not logged</td>
  155. <td>not logged</td>
  156. <td>ok</td>
  157. </tr>
  158. </table>
  159. </body>
  160. </html>