|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
- <html>
-
- <head>
- <meta http-equiv="Content-Language" content="en-us">
- <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
- <title>Echo Task</title>
- </head>
-
- <body>
-
- <h2 id="echo">Echo</h2>
- <h3>Description</h3>
- <p>Echoes a message to the current loggers and listeners which means <code>System.out</code> unless
- overridden. A <var>level</var> can be specified, which controls at what logging level the message is
- filtered at.</p>
- <p>The task can also echo to a file, in which case the option to append rather than overwrite the
- file is available, and the <var>level</var> option is ignored</p>
- <h3>Parameters</h3>
- <table class="attr">
- <tr>
- <th>Attribute</th>
- <th>Description</th>
- <th>Required</th>
- </tr>
- <tr>
- <td>message</td>
- <td>the message to echo.</td>
- <td>No; defaults to a blank line unless text is included in a character section within this
- element</td>
- </tr>
- <tr>
- <td>file</td>
- <td>the file to write the message to.</td>
- <td rowspan="2">No; only one of these may be used</td>
- </tr>
- <tr>
- <td>output</td>
- <td class="left">the <a href="../Types/resources.html">Resource</a>
- to write the message to (see <a href="../develop.html#set-magic">note</a>).
- <em>Since Apache Ant 1.8</em></td>
- </tr>
- <tr>
- <td>append</td>
- <td>Append to an existing file
- (or <a href="https://docs.oracle.com/javase/8/docs/api//java/io/FileWriter.html#FileWriter-java.lang.String-boolean-"
- target="_blank"> open a new file / overwrite an existing file</a>)?
- </td>
- <td>No; ignored unless <var>output</var> indicates a filesystem destination, default
- is <q>false</q></td>
- </tr>
- <tr>
- <td>level</td>
- <td>Control the level at which this message is reported. One
- of <q>error</q>, <q>warning</q>, <q>info</q>, <q>verbose</q>, <q>debug</q> (decreasing
- order)</td>
- <td>No; default is <q>warning</q></td>
- </tr>
- <tr>
- <td>encoding</td>
- <td>encoding to use. <em>since Ant 1.7</em></td>
- <td>No; defaults to default JVM character encoding</td>
- </tr>
- <tr>
- <td>force</td>
- <td>Overwrite read-only destination files. <em>since Ant 1.8.2</em></td>
- <td>No; defaults to <q>false</q></td>
- </tr>
- </table>
-
- <h3>Examples</h3>
- <pre><echo message="Hello, world"/></pre>
- <pre><echo message="Embed a line break:${line.separator}"/></pre>
- <pre><echo>Embed another:${line.separator}</echo></pre>
- <pre><echo>This is a longer message stretching over
- two lines.
- </echo></pre>
- <pre><echo>
- This is a longer message stretching over
- three lines; the first line is a blank
- </echo></pre>
- <p>The newline immediately following the <code><echo></code> tag will be part of the
- output. Newlines in character data within the content of an element are not discarded by XML
- parsers.<br/>See <a href="https://www.w3.org/TR/xml/#sec-line-ends">W3C Recommendation 26 November
- 2008 / End of Line handling</a> for more details.</p>
-
- <pre><echo message="Deleting drive C:" level="debug"/></pre>
- <p>A message which only appears in <code>-debug</code> mode.</p>
- <pre><echo level="error">
- Imminent failure in the antimatter containment facility.
- Please withdraw to safe location at least 50km away.
- </echo></pre>
- <p>A message which appears even in <code>-quiet</code> mode.</p>
-
- <pre><echo file="runner.csh" append="false">#\!/bin/tcsh
- java-1.3.1 -mx1024m ${project.entrypoint} $$*
- </echo></pre>
- <p>Generate a shell script by echoing to a file. Note the use of a double <q>$</q> symbol to stop
- Ant filtering out the single <q>$</q> during variable expansion.</p>
-
- <p>Depending on the log level Ant runs at, messages are print out or silently ignored:</p>
- <table>
- <tr>
- <th>Ant command line</th>
- <th><code>-quiet</code>, <code>-q</code></th>
- <th><em>no switch</em></th>
- <th><code>-verbose</code>, <code>-v</code></th>
- <th><code>-debug</code>, <code>-d</code></th>
- </tr>
- <tr>
- <td><pre><echo message="This is error message." level="error"/></pre></td>
- <td>ok</td>
- <td>ok</td>
- <td>ok</td>
- <td>ok</td>
- </tr>
- <tr>
- <td><pre><echo message="This is warning message."/></pre></td>
- <td>ok</td>
- <td>ok</td>
- <td>ok</td>
- <td>ok</td>
- </tr>
- <tr>
- <td><pre><echo message="This is warning message." level="warning"/></pre></td>
- <td>ok</td>
- <td>ok</td>
- <td>ok</td>
- <td>ok</td>
- </tr>
- <tr>
- <td><pre><echo message="This is info message." level="info"/></pre></td>
- <td>not logged</td>
- <td>ok</td>
- <td>ok</td>
- <td>ok</td>
- </tr>
- <tr>
- <td><pre><echo message="This is verbose message." level="verbose"/></pre></td>
- <td>not logged</td>
- <td>not logged</td>
- <td>ok</td>
- <td>ok</td>
- </tr>
- <tr>
- <td><pre><echo message="This is debug message." level="debug"/></pre></td>
- <td>not logged</td>
- <td>not logged</td>
- <td>not logged</td>
- <td>ok</td>
- </tr>
- </table>
-
- </body>
- </html>
|