FileDocCategorySizeDatePackage
Echo.javaAPI DocApache Ant 1.704499Wed Dec 13 06:16:18 GMT 2006org.apache.tools.ant.taskdefs

Echo

public class Echo extends org.apache.tools.ant.Task
Writes a message to the Ant logging facilities.
since
Ant 1.1
ant.task
category="utility"

Fields Summary
protected String
message
protected File
file
protected boolean
append
private String
encoding
encoding; set to null or empty means 'default'
protected int
logLevel
Constructors Summary
Methods Summary
public voidaddText(java.lang.String msg)
Set a multiline message.

param
msg the CDATA text to append to the output text

        message += getProject().replaceProperties(msg);
    
public voidexecute()
Does the work.

exception
BuildException if something goes wrong with the build

    // CheckStyle:VisibilityModifier ON

                     
         
        if (file == null) {
            log(message, logLevel);
        } else {
            Writer out = null;
            try {
                String filename = file.getAbsolutePath();
                if (encoding == null || encoding.length() == 0) {
                    out = new FileWriter(filename, append);
                } else {
                    out = new BufferedWriter(
                            new OutputStreamWriter(
                                new FileOutputStream(filename, append), encoding));
                }
                out.write(message, 0, message.length());
            } catch (IOException ioe) {
                throw new BuildException(ioe, getLocation());
            } finally {
                FileUtils.close(out);
            }
        }
    
public voidsetAppend(boolean append)
If true, append to existing file.

param
append if true, append to existing file, default is false.

        this.append = append;
    
public voidsetEncoding(java.lang.String encoding)
Declare the encoding to use when outputting to a file; Use "" for the platform's default encoding.

param
encoding the character encoding to use.
since
1.7

        this.encoding = encoding;
    
public voidsetFile(java.io.File file)
File to write to.

param
file the file to write to, if not set, echo to standard output

        this.file = file;
    
public voidsetLevel(org.apache.tools.ant.taskdefs.Echo$EchoLevel echoLevel)
Set the logging level. Level should be one of
  • error
  • warning
  • info
  • verbose
  • debug

The default is "warning" to ensure that messages are displayed by default when using the -quiet command line option.

param
echoLevel the logging level

        logLevel = echoLevel.getLevel();
    
public voidsetMessage(java.lang.String msg)
Message to write.

param
msg Sets the value for the message variable.

        this.message = msg;