git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273938 13f79535-47bb-0310-9956-ffa450edef68master
@@ -191,7 +191,9 @@ public class DemuxOutputStream extends OutputStream { | |||
* @see Project#demuxOutput(String,boolean) | |||
*/ | |||
protected void processBuffer(ByteArrayOutputStream buffer) { | |||
processBuffer(buffer, true); | |||
String output = buffer.toString(); | |||
project.demuxOutput(output, isErrorStream); | |||
resetBufferInfo(); | |||
} | |||
/** | |||
@@ -202,10 +204,9 @@ public class DemuxOutputStream extends OutputStream { | |||
* | |||
* @see Project#demuxOutput(String,boolean) | |||
*/ | |||
protected void processBuffer(ByteArrayOutputStream buffer, | |||
boolean terminated) { | |||
protected void processFlush(ByteArrayOutputStream buffer) { | |||
String output = buffer.toString(); | |||
project.demuxOutput(output, isErrorStream, terminated); | |||
project.demuxFlush(output, isErrorStream); | |||
resetBufferInfo(); | |||
} | |||
@@ -230,7 +231,7 @@ public class DemuxOutputStream extends OutputStream { | |||
public void flush() throws IOException { | |||
BufferInfo bufferInfo = getBufferInfo(); | |||
if (bufferInfo.buffer.size() > 0) { | |||
processBuffer(bufferInfo.buffer, false); | |||
processFlush(bufferInfo.buffer); | |||
} | |||
} | |||
} |
@@ -1228,29 +1228,40 @@ public class Project { | |||
* or information (<code>false</code>). | |||
*/ | |||
public void demuxOutput(String line, boolean isError) { | |||
demuxOutput(line, isError, true); | |||
Task task = (Task) threadTasks.get(Thread.currentThread()); | |||
if (task == null) { | |||
fireMessageLogged(this, line, isError ? MSG_ERR : MSG_INFO); | |||
} else { | |||
if (isError) { | |||
task.handleErrorOutput(line); | |||
} else { | |||
task.handleOutput(line); | |||
} | |||
} | |||
} | |||
/** | |||
* Demultiplexes output so that each task receives the appropriate | |||
* Demultiplexes flush operation so that each task receives the appropriate | |||
* messages. If the current thread is not currently executing a task, | |||
* the message is logged directly. | |||
* | |||
* @since Ant 1.5.2 | |||
* | |||
* @param line Message to handle. Should not be <code>null</code>. | |||
* @param isError Whether the text represents an error (<code>true</code>) | |||
* or information (<code>false</code>). | |||
* @param terminated true if this line should be terminated with an | |||
* end-of-line marker | |||
*/ | |||
public void demuxOutput(String line, boolean isError, boolean terminated) { | |||
public void demuxFlush(String line, boolean isError) { | |||
Task task = (Task) threadTasks.get(Thread.currentThread()); | |||
if (task == null) { | |||
fireMessageLogged(this, line, isError ? MSG_ERR : MSG_INFO); | |||
} else { | |||
if (isError) { | |||
task.handleErrorOutput(line, terminated); | |||
task.handleErrorFlush(line); | |||
} else { | |||
task.handleOutput(line, terminated); | |||
task.handleFlush(line); | |||
} | |||
} | |||
} | |||
@@ -298,18 +298,18 @@ public abstract class Task extends ProjectComponent { | |||
* @param line The line of output to log. Should not be <code>null</code>. | |||
*/ | |||
protected void handleOutput(String line) { | |||
handleOutput(line + "X7", true); | |||
log(line, Project.MSG_INFO); | |||
} | |||
/** | |||
* Handles a line of output by logging it with the INFO priority. | |||
* | |||
* @param line The line of output to log. Should not be <code>null</code>. | |||
* @param terminated true if this line should be terminated with an | |||
* end-of-line marker | |||
* | |||
* @since Ant 1.5.2 | |||
*/ | |||
protected void handleOutput(String line, boolean terminated) { | |||
log(line, Project.MSG_INFO); | |||
protected void handleFlush(String line) { | |||
handleOutput(line); | |||
} | |||
/** | |||
@@ -318,18 +318,18 @@ public abstract class Task extends ProjectComponent { | |||
* @param line The error line to log. Should not be <code>null</code>. | |||
*/ | |||
protected void handleErrorOutput(String line) { | |||
handleErrorOutput(line, true); | |||
log(line, Project.MSG_ERR); | |||
} | |||
/** | |||
* Handles an error line by logging it with the INFO priority. | |||
* | |||
* @param line The error line to log. Should not be <code>null</code>. | |||
* @param terminated true if this line should be terminated with an | |||
* end-of-line marker | |||
* | |||
* @since Ant 1.5.2 | |||
*/ | |||
protected void handleErrorOutput(String line, boolean terminated) { | |||
log(line, Project.MSG_ERR); | |||
protected void handleErrorFlush(String line) { | |||
handleErrorOutput(line); | |||
} | |||
/** | |||
@@ -161,11 +161,11 @@ public class UnknownElement extends Task { | |||
* | |||
* @param line The line of output to log. Should not be <code>null</code>. | |||
*/ | |||
protected void handleOutput(String line, boolean terminated) { | |||
protected void handleFlush(String line) { | |||
if (realThing instanceof Task) { | |||
((Task) realThing).handleOutput(line, terminated); | |||
((Task) realThing).handleFlush(line); | |||
} else { | |||
super.handleOutput(line, terminated); | |||
super.handleFlush(line); | |||
} | |||
} | |||
@@ -188,11 +188,11 @@ public class UnknownElement extends Task { | |||
* | |||
* @param line The error line to log. Should not be <code>null</code>. | |||
*/ | |||
protected void handleErrorOutput(String line, boolean terminated) { | |||
protected void handleErrorFlush(String line) { | |||
if (realThing instanceof Task) { | |||
((Task) realThing).handleErrorOutput(line, terminated); | |||
((Task) realThing).handleErrorOutput(line); | |||
} else { | |||
super.handleErrorOutput(line, terminated); | |||
super.handleErrorOutput(line); | |||
} | |||
} | |||
@@ -288,7 +288,7 @@ public class Ant extends Task { | |||
* | |||
* @since Ant 1.5 | |||
*/ | |||
protected void handleOutput(String line) { | |||
public void handleOutput(String line) { | |||
if (newProject != null) { | |||
newProject.demuxOutput(line, false); | |||
} else { | |||
@@ -299,13 +299,13 @@ public class Ant extends Task { | |||
/** | |||
* Pass output sent to System.out to the new project. | |||
* | |||
* @since Ant 1.6 | |||
* @since Ant 1.5.2 | |||
*/ | |||
protected void handleOutput(String line, boolean terminated) { | |||
public void handleFlush(String line) { | |||
if (newProject != null) { | |||
newProject.demuxOutput(line, false, terminated); | |||
newProject.demuxFlush(line, false); | |||
} else { | |||
super.handleOutput(line, terminated); | |||
super.handleFlush(line); | |||
} | |||
} | |||
@@ -314,7 +314,7 @@ public class Ant extends Task { | |||
* | |||
* @since Ant 1.5 | |||
*/ | |||
protected void handleErrorOutput(String line) { | |||
public void handleErrorOutput(String line) { | |||
if (newProject != null) { | |||
newProject.demuxOutput(line, true); | |||
} else { | |||
@@ -325,13 +325,13 @@ public class Ant extends Task { | |||
/** | |||
* Pass output sent to System.err to the new project. | |||
* | |||
* @since Ant 1.6 | |||
* @since Ant 1.5.2 | |||
*/ | |||
protected void handleErrorOutput(String line, boolean terminated) { | |||
public void handleErrorFlush(String line) { | |||
if (newProject != null) { | |||
newProject.demuxOutput(line, true, terminated); | |||
newProject.demuxFlush(line, true); | |||
} else { | |||
super.handleErrorOutput(line, terminated); | |||
super.handleErrorFlush(line); | |||
} | |||
} | |||
@@ -188,13 +188,13 @@ public class CallTarget extends Task { | |||
/** | |||
* Pass output sent to System.out to the new project. | |||
* | |||
* @since Ant 1.6 | |||
* @since Ant 1.5.2 | |||
*/ | |||
protected void handleOutput(String line, boolean terminated) { | |||
public void handleFlush(String line) { | |||
if (callee != null) { | |||
callee.handleOutput(line, terminated); | |||
callee.handleFlush(line); | |||
} else { | |||
super.handleOutput(line, terminated); | |||
super.handleFlush(line); | |||
} | |||
} | |||
@@ -214,13 +214,13 @@ public class CallTarget extends Task { | |||
/** | |||
* Pass output sent to System.err to the new project. | |||
* | |||
* @since Ant 1.6 | |||
* @since Ant 1.5.2 | |||
*/ | |||
protected void handleErrorOutput(String line, boolean terminated) { | |||
public void handleErrorFlush(String line) { | |||
if (callee != null) { | |||
callee.handleErrorOutput(line, terminated); | |||
callee.handleErrorFlush(line); | |||
} else { | |||
super.handleErrorOutput(line, terminated); | |||
super.handleErrorFlush(line); | |||
} | |||
} | |||
} |
@@ -376,17 +376,13 @@ public class Java extends Task { | |||
/** | |||
* Pass output sent to System.out to specified output file. | |||
* | |||
* @since Ant 1.6 | |||
* @since Ant 1.5.2 | |||
*/ | |||
protected void handleOutput(String line, boolean terminated) { | |||
protected void handleFlush(String line) { | |||
if (outStream != null) { | |||
if (terminated) { | |||
outStream.println(line); | |||
} else { | |||
outStream.print(line); | |||
} | |||
outStream.print(line); | |||
} else { | |||
super.handleOutput(line, terminated); | |||
super.handleFlush(line); | |||
} | |||
} | |||
@@ -406,17 +402,13 @@ public class Java extends Task { | |||
/** | |||
* Pass output sent to System.err to specified output file. | |||
* | |||
* @since Ant 1.6 | |||
* @since Ant 1.5.2 | |||
*/ | |||
protected void handleErrorOutput(String line, boolean terminated) { | |||
protected void handleErrorFlush(String line) { | |||
if (outStream != null) { | |||
if (terminated) { | |||
outStream.println(line); | |||
} else { | |||
outStream.print(line); | |||
} | |||
outStream.println(line); | |||
} else { | |||
super.handleErrorOutput(line, terminated); | |||
super.handleErrorOutput(line); | |||
} | |||
} | |||
@@ -717,16 +717,16 @@ public class JUnitTask extends Task { | |||
* Pass output sent to System.out to the TestRunner so it can | |||
* collect ot for the formatters. | |||
* | |||
* @since Ant 1.6 | |||
* @since Ant 1.5.2 | |||
*/ | |||
protected void handleOutput(String line, boolean terminated) { | |||
protected void handleFlush(String line) { | |||
if (runner != null) { | |||
runner.handleOutput(line, terminated); | |||
runner.handleFlush(line); | |||
if (showOutput) { | |||
super.handleOutput(line, terminated); | |||
super.handleFlush(line); | |||
} | |||
} else { | |||
super.handleOutput(line, terminated); | |||
super.handleFlush(line); | |||
} | |||
} | |||
@@ -736,7 +736,7 @@ public class JUnitTask extends Task { | |||
* | |||
* @since Ant 1.5 | |||
*/ | |||
protected void handleErrorOutput(String line) { | |||
public void handleErrorOutput(String line) { | |||
if (runner != null) { | |||
runner.handleErrorOutput(line); | |||
if (showOutput) { | |||
@@ -752,16 +752,16 @@ public class JUnitTask extends Task { | |||
* Pass output sent to System.err to the TestRunner so it can | |||
* collect ot for the formatters. | |||
* | |||
* @since Ant 1.6 | |||
* @since Ant 1.5.2 | |||
*/ | |||
protected void handleErrorOutput(String line, boolean terminated) { | |||
public void handleErrorFlush(String line) { | |||
if (runner != null) { | |||
runner.handleErrorOutput(line, terminated); | |||
runner.handleErrorFlush(line); | |||
if (showOutput) { | |||
super.handleErrorOutput(line, terminated); | |||
super.handleErrorFlush(line); | |||
} | |||
} else { | |||
super.handleErrorOutput(line, terminated); | |||
super.handleErrorFlush(line); | |||
} | |||
} | |||
@@ -416,23 +416,15 @@ public class JUnitTestRunner implements TestListener { | |||
} | |||
} | |||
protected void handleOutput(String line, boolean terminated) { | |||
protected void handleFlush(String line) { | |||
if (systemOut != null) { | |||
if (terminated) { | |||
systemOut.println(line); | |||
} else { | |||
systemOut.print(line); | |||
} | |||
systemOut.print(line); | |||
} | |||
} | |||
protected void handleErrorOutput(String line, boolean terminated) { | |||
protected void handleErrorFlush(String line) { | |||
if (systemError != null) { | |||
if (terminated) { | |||
systemError.println(line); | |||
} else { | |||
systemError.print(line); | |||
} | |||
systemError.print(line); | |||
} | |||
} | |||