Reader reader = new InputStreamReader(outPumpIn,
inputEncoding);
if (outputFilterChains != null
&& outputFilterChains.size() > 0) {
ChainReaderHelper helper = new ChainReaderHelper();
helper.setProject(managingTask.getProject());
helper.setPrimaryReader(reader);
helper.setFilterChains(outputFilterChains);
reader = helper.getAssembledReader();
}
outPumpIn = new ReaderInputStream(reader, outputEncoding);
Thread t = new Thread(threadGroup, new StreamPumper(
outPumpIn, outputStream, true), "output pumper");
t.setPriority(Thread.MAX_PRIORITY);
outputStream = new PipedOutputStream(snk);
t.start();
} catch (IOException eyeOhEx) {
throw new BuildException("error setting up output stream",
eyeOhEx);
}
}
}
synchronized (errMutex) {
errorStreams();
if (alwaysLogErr || errorStream == null) {
OutputStream errorLog = new LogOutputStream(managingTask,
Project.MSG_WARN);
errorStream = (errorStream == null) ? errorLog
: new TeeOutputStream(errorLog, errorStream);
}
if ((errorFilterChains != null && errorFilterChains.size() > 0)
|| !(errorEncoding.equalsIgnoreCase(inputEncoding))) {
try {
LeadPipeInputStream snk = new LeadPipeInputStream();
snk.setManagingComponent(managingTask);
InputStream errPumpIn = snk;
Reader reader = new InputStreamReader(errPumpIn,
inputEncoding);
if (errorFilterChains != null
&& errorFilterChains.size() > 0) {
ChainReaderHelper helper = new ChainReaderHelper();
helper.setProject(managingTask.getProject());
helper.setPrimaryReader(reader);
helper.setFilterChains(errorFilterChains);
reader = helper.getAssembledReader();
}
errPumpIn = new ReaderInputStream(reader, errorEncoding);
Thread t = new Thread(threadGroup, new StreamPumper(
errPumpIn, errorStream, true), "error pumper");
t.setPriority(Thread.MAX_PRIORITY);
errorStream = new PipedOutputStream(snk);
t.start();
} catch (IOException eyeOhEx) {
throw new BuildException("error setting up error stream",
eyeOhEx);
}
}
}
synchronized (inMutex) {
// if input files are specified, inputString and inputStream are
// ignored;
// classes that work with redirector attributes can enforce
// whatever warnings are needed
if (input != null && input.length > 0) {
managingTask
.log("Redirecting input from file"
+ ((input.length == 1) ? "" : "s"),
Project.MSG_VERBOSE);
try {
inputStream = new ConcatFileInputStream(input);
} catch (IOException eyeOhEx) {
throw new BuildException(eyeOhEx);
}
((ConcatFileInputStream) inputStream)
.setManagingComponent(managingTask);
} else if (inputString != null) {
StringBuffer buf = new StringBuffer("Using input ");
if (logInputString) {
buf.append('"').append(inputString).append('"');
} else {
buf.append("string");
}
managingTask.log(buf.toString(), Project.MSG_VERBOSE);
inputStream = new ByteArrayInputStream(inputString.getBytes());
}
if (inputStream != null && inputFilterChains != null
&& inputFilterChains.size() > 0) {
ChainReaderHelper helper = new ChainReaderHelper();
helper.setProject(managingTask.getProject());
try {
helper.setPrimaryReader(new InputStreamReader(inputStream,
inputEncoding));
} catch (IOException eyeOhEx) {
throw new BuildException("error setting up input stream",
eyeOhEx);
}
helper.setFilterChains(inputFilterChains);
inputStream = new ReaderInputStream(
helper.getAssembledReader(), inputEncoding);
}
}
}