Search in sources :

Example 1 with LineOrientedOutputStreamRedirector

use of org.apache.tools.ant.util.LineOrientedOutputStreamRedirector in project ant by apache.

the class Redirector method errorStreams.

private void errorStreams() {
    if (error != null && error.length > 0) {
        final String logHead = "Error " + ((appendErr) ? "appended" : "redirected") + " to ";
        errorStream = foldFiles(error, logHead, Project.MSG_VERBOSE, appendErr, createEmptyFilesErr);
    } else if (!(logError || outputStream == null) && errorProperty == null) {
        final long funnelTimeout = 0L;
        final OutputStreamFunneler funneler = new OutputStreamFunneler(outputStream, funnelTimeout);
        try {
            outputStream = funneler.getFunnelInstance();
            errorStream = funneler.getFunnelInstance();
            if (!outputIsBinary) {
                outputStream = new LineOrientedOutputStreamRedirector(outputStream);
                errorStream = new LineOrientedOutputStreamRedirector(errorStream);
            }
        } catch (final IOException eyeOhEx) {
            throw new BuildException("error splitting output/error streams", eyeOhEx);
        }
    }
    if (errorProperty != null) {
        if (errorBaos == null) {
            errorBaos = new PropertyOutputStream(errorProperty);
            managingTask.log("Error redirected to property: " + errorProperty, Project.MSG_VERBOSE);
        }
        // shield it from being closed by a filtering StreamPumper
        final OutputStream keepAliveError = new KeepAliveOutputStream(errorBaos);
        errorStream = (error == null || error.length == 0) ? keepAliveError : new TeeOutputStream(errorStream, keepAliveError);
    } else {
        errorBaos = null;
    }
}
Also used : OutputStreamFunneler(org.apache.tools.ant.util.OutputStreamFunneler) TeeOutputStream(org.apache.tools.ant.util.TeeOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) KeepAliveOutputStream(org.apache.tools.ant.util.KeepAliveOutputStream) OutputStream(java.io.OutputStream) LazyFileOutputStream(org.apache.tools.ant.util.LazyFileOutputStream) PipedOutputStream(java.io.PipedOutputStream) TeeOutputStream(org.apache.tools.ant.util.TeeOutputStream) KeepAliveOutputStream(org.apache.tools.ant.util.KeepAliveOutputStream) LineOrientedOutputStreamRedirector(org.apache.tools.ant.util.LineOrientedOutputStreamRedirector) IOException(java.io.IOException) BuildException(org.apache.tools.ant.BuildException)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 PipedOutputStream (java.io.PipedOutputStream)1 BuildException (org.apache.tools.ant.BuildException)1 KeepAliveOutputStream (org.apache.tools.ant.util.KeepAliveOutputStream)1 LazyFileOutputStream (org.apache.tools.ant.util.LazyFileOutputStream)1 LineOrientedOutputStreamRedirector (org.apache.tools.ant.util.LineOrientedOutputStreamRedirector)1 OutputStreamFunneler (org.apache.tools.ant.util.OutputStreamFunneler)1 TeeOutputStream (org.apache.tools.ant.util.TeeOutputStream)1