Search in sources :

Example 1 with InfoOutputStream

use of org.robovm.compiler.log.InfoOutputStream in project robovm by robovm.

the class Executor method initExecutor.

private <T extends org.apache.commons.exec.Executor> T initExecutor(T executor) {
    if (streamHandler == null) {
        OutputStream pumpOut = null;
        OutputStream pumpErr = null;
        InputStream pumpIn = null;
        if (out != null) {
            pumpOut = out;
        } else {
            pumpOut = new InfoOutputStream(logger);
        }
        if (err != null) {
            pumpErr = err;
        } else {
            pumpErr = new ErrorOutputStream(logger);
        }
        if (in != null) {
            pumpIn = in;
        }
        if (pumpOut == System.out) {
            pumpOut = new NeverCloseOutputStream(pumpOut);
        }
        if (pumpErr == System.err) {
            pumpErr = new NeverCloseOutputStream(pumpErr);
        }
        executor.setStreamHandler(new PumpStreamHandler(pumpOut, pumpErr, pumpIn) {

            @Override
            protected Thread createPump(InputStream is, OutputStream os, boolean closeWhenExhausted) {
                return super.createPump(is, os, closeOutputStreams ? true : closeWhenExhausted);
            }
        });
    } else {
        executor.setStreamHandler(streamHandler);
    }
    if (wd != null) {
        executor.setWorkingDirectory(wd);
    }
    executor.setExitValue(0);
    return executor;
}
Also used : PumpStreamHandler(org.apache.commons.exec.PumpStreamHandler) ErrorOutputStream(org.robovm.compiler.log.ErrorOutputStream) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) NeverCloseOutputStream(org.robovm.compiler.util.io.NeverCloseOutputStream) InfoOutputStream(org.robovm.compiler.log.InfoOutputStream) ErrorOutputStream(org.robovm.compiler.log.ErrorOutputStream) NeverCloseOutputStream(org.robovm.compiler.util.io.NeverCloseOutputStream) InfoOutputStream(org.robovm.compiler.log.InfoOutputStream)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 PumpStreamHandler (org.apache.commons.exec.PumpStreamHandler)1 ErrorOutputStream (org.robovm.compiler.log.ErrorOutputStream)1 InfoOutputStream (org.robovm.compiler.log.InfoOutputStream)1 NeverCloseOutputStream (org.robovm.compiler.util.io.NeverCloseOutputStream)1