use of org.apache.tools.ant.util.KeepAliveOutputStream in project ant by apache.
the class Redirector method outStreams.
/**
* outStreams
*/
private void outStreams() {
if (out != null && out.length > 0) {
final String logHead = "Output " + ((appendOut) ? "appended" : "redirected") + " to ";
outputStream = foldFiles(out, logHead, Project.MSG_VERBOSE, appendOut, createEmptyFilesOut);
}
if (outputProperty != null) {
if (baos == null) {
baos = new PropertyOutputStream(outputProperty);
managingTask.log("Output redirected to property: " + outputProperty, Project.MSG_VERBOSE);
}
// shield it from being closed by a filtering StreamPumper
final OutputStream keepAliveOutput = new KeepAliveOutputStream(baos);
outputStream = (outputStream == null) ? keepAliveOutput : new TeeOutputStream(outputStream, keepAliveOutput);
} else {
baos = null;
}
}
use of org.apache.tools.ant.util.KeepAliveOutputStream 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;
}
}
use of org.apache.tools.ant.util.KeepAliveOutputStream in project ant by apache.
the class JUnitLauncherTask method setupResultFormatter.
private void setupResultFormatter(final TestRequest testRequest, final ListenerDefinition formatterDefinition, final TestResultFormatter resultFormatter) {
testRequest.closeUponCompletion(resultFormatter);
// set the execution context
resultFormatter.setContext(new InVMExecution());
// set the destination output stream for writing out the formatted result
final TestDefinition test = testRequest.getOwner();
final java.nio.file.Path outputDir = test.getOutputDir() != null ? Paths.get(test.getOutputDir()) : getProject().getBaseDir().toPath();
final String filename = formatterDefinition.requireResultFile(test);
final java.nio.file.Path resultOutputFile = Paths.get(outputDir.toString(), filename);
try {
final OutputStream resultOutputStream = Files.newOutputStream(resultOutputFile);
// enroll the output stream to be closed when the execution of the TestRequest completes
testRequest.closeUponCompletion(resultOutputStream);
resultFormatter.setDestination(new KeepAliveOutputStream(resultOutputStream));
} catch (IOException e) {
throw new BuildException(e);
}
// check if system.out/system.err content needs to be passed on to the listener
if (formatterDefinition.shouldSendSysOut()) {
testRequest.addSysOutInterest(resultFormatter);
}
if (formatterDefinition.shouldSendSysErr()) {
testRequest.addSysErrInterest(resultFormatter);
}
}
Aggregations