conor 2003/07/17 03:20:16 Modified: src/main/org/apache/tools/ant DemuxOutputStream.java Project.java Task.java UnknownElement.java src/main/org/apache/tools/ant/taskdefs Ant.java CallTarget.java Java.java Redirector.java src/main/org/apache/tools/ant/taskdefs/optional/junit JUnitTask.java JUnitTestRunner.java src/testcases/org/apache/tools/ant/taskdefs DefaultExcludesTest.java DemuxOutputTask.java Log: Ensure all generated output gets through the output system to the generating task PR: 21636 Revision Changes Path 1.15 +18 -13 ant/src/main/org/apache/tools/ant/DemuxOutputStream.java Index: DemuxOutputStream.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/DemuxOutputStream.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -w -u -r1.14 -r1.15 --- DemuxOutputStream.java 6 Jul 2003 09:57:34 -0000 1.14 +++ DemuxOutputStream.java 17 Jul 2003 10:20:13 -0000 1.15 @@ -80,11 +80,10 @@ private ByteArrayOutputStream buffer; /** - * Whether or not the next line-terminator should be skipped in terms - * of processing the buffer. Used to avoid \r\n invoking - * processBuffer twice. + * Indicates we have just seen a carriage return. It may be part of + * a crlf pair or a single cr invoking processBuffer twice. */ - private boolean skip = false; + private boolean crSeen = false; } /** Maximum buffer size. */ @@ -129,7 +128,7 @@ if (bufferInfo == null) { bufferInfo = new BufferInfo(); bufferInfo.buffer = new ByteArrayOutputStream(); - bufferInfo.skip = false; + bufferInfo.crSeen = false; buffers.put(current, bufferInfo); } return bufferInfo; @@ -147,7 +146,7 @@ // Shouldn't happen } bufferInfo.buffer = new ByteArrayOutputStream(); - bufferInfo.skip = false; + bufferInfo.crSeen = false; } /** @@ -169,17 +168,23 @@ final byte c = (byte) cc; BufferInfo bufferInfo = getBufferInfo(); - if ((c == '\n') || (c == '\r')) { - if (!bufferInfo.skip) { + + if (c == '\n') { + // LF is always end of line (i.e. CRLF or single LF) + bufferInfo.buffer.write(cc); processBuffer(bufferInfo.buffer); - } } else { - bufferInfo.buffer.write(cc); - if (bufferInfo.buffer.size() > MAX_SIZE) { + if (bufferInfo.crSeen) { + // CR without LF - send buffer then add char processBuffer(bufferInfo.buffer); } + // add into buffer + bufferInfo.buffer.write(cc); + } + bufferInfo.crSeen = (c == '\r'); + if (!bufferInfo.crSeen && bufferInfo.buffer.size() > MAX_SIZE) { + processBuffer(bufferInfo.buffer); } - bufferInfo.skip = (c == '\r'); } /** 1.146 +20 -12 ant/src/main/org/apache/tools/ant/Project.java Index: Project.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/Project.java,v retrieving revision 1.145 retrieving revision 1.146 diff -u -w -u -r1.145 -r1.146 --- Project.java 16 Jul 2003 14:13:53 -0000 1.145 +++ Project.java 17 Jul 2003 10:20:14 -0000 1.146 @@ -75,6 +75,8 @@ import org.apache.tools.ant.types.Path; import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.util.JavaEnvUtils; +import org.apache.tools.ant.util.StringUtils; + /** * Central representation of an Ant project. This class defines an @@ -1089,19 +1091,19 @@ * messages. If the current thread is not currently executing a task, * the message is logged directly. * - * @param line Message to handle. Should not be <code>null</code>. + * @param output 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>). */ - public void demuxOutput(String line, boolean isError) { + public void demuxOutput(String output, boolean isError) { Task task = getThreadTask(Thread.currentThread()); if (task == null) { - fireMessageLogged(this, line, isError ? MSG_ERR : MSG_INFO); + log(output, isError ? MSG_ERR : MSG_INFO); } else { if (isError) { - task.handleErrorOutput(line); + task.handleErrorOutput(output); } else { - task.handleOutput(line); + task.handleOutput(output); } } } @@ -1158,19 +1160,19 @@ * * @since Ant 1.5.2 * - * @param line Message to handle. Should not be <code>null</code>. + * @param output 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>). */ - public void demuxFlush(String line, boolean isError) { + public void demuxFlush(String output, boolean isError) { Task task = getThreadTask(Thread.currentThread()); if (task == null) { - fireMessageLogged(this, line, isError ? MSG_ERR : MSG_INFO); + fireMessageLogged(this, output, isError ? MSG_ERR : MSG_INFO); } else { if (isError) { - task.handleErrorFlush(line); + task.handleErrorFlush(output); } else { - task.handleFlush(line); + task.handleFlush(output); } } } @@ -1915,7 +1917,13 @@ */ private void fireMessageLoggedEvent(BuildEvent event, String message, int priority) { + + if (message.endsWith(StringUtils.LINE_SEP)) { + int endIndex = message.length() - StringUtils.LINE_SEP.length(); + event.setMessage(message.substring(0, endIndex), priority); + } else { event.setMessage(message, priority); + } Vector listeners = getBuildListeners(); synchronized (this) { if (loggingMessage) { 1.45 +15 -15 ant/src/main/org/apache/tools/ant/Task.java Index: Task.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/Task.java,v retrieving revision 1.44 retrieving revision 1.45 diff -u -w -u -r1.44 -r1.45 --- Task.java 6 Jul 2003 09:57:34 -0000 1.44 +++ Task.java 17 Jul 2003 10:20:14 -0000 1.45 @@ -305,23 +305,23 @@ } /** - * Handles a line of output by logging it with the INFO priority. + * Handles output by logging it with the INFO priority. * - * @param line The line of output to log. Should not be <code>null</code>. + * @param output The output to log. Should not be <code>null</code>. */ - protected void handleOutput(String line) { - log(line, Project.MSG_INFO); + protected void handleOutput(String output) { + log(output, Project.MSG_INFO); } /** - * Handles a line of output by logging it with the INFO priority. + * Handles output by logging it with the INFO priority. * - * @param line The line of output to log. Should not be <code>null</code>. + * @param output The output to log. Should not be <code>null</code>. * * @since Ant 1.5.2 */ - protected void handleFlush(String line) { - handleOutput(line); + protected void handleFlush(String output) { + handleOutput(output); } /** @@ -342,23 +342,23 @@ } /** - * Handles an error line by logging it with the INFO priority. + * Handles an error output by logging it with the INFO priority. * - * @param line The error line to log. Should not be <code>null</code>. + * @param output The error output to log. Should not be <code>null</code>. */ - protected void handleErrorOutput(String line) { - log(line, Project.MSG_ERR); + protected void handleErrorOutput(String output) { + log(output, 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 output The error output to log. Should not be <code>null</code>. * * @since Ant 1.5.2 */ - protected void handleErrorFlush(String line) { - handleErrorOutput(line); + protected void handleErrorFlush(String output) { + handleErrorOutput(output); } /** 1.55 +16 -16 ant/src/main/org/apache/tools/ant/UnknownElement.java Index: UnknownElement.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/UnknownElement.java,v retrieving revision 1.54 retrieving revision 1.55 diff -u -w -u -r1.54 -r1.55 --- UnknownElement.java 6 Jul 2003 09:57:34 -0000 1.54 +++ UnknownElement.java 17 Jul 2003 10:20:14 -0000 1.55 @@ -192,13 +192,13 @@ /** * Handles output sent to System.out by this task or its real task. * - * @param line The line of output to log. Should not be <code>null</code>. + * @param output The output to log. Should not be <code>null</code>. */ - protected void handleOutput(String line) { + protected void handleOutput(String output) { if (realThing instanceof Task) { - ((Task) realThing).handleOutput(line); + ((Task) realThing).handleOutput(output); } else { - super.handleOutput(line); + super.handleOutput(output); } } @@ -219,26 +219,26 @@ /** * Handles output sent to System.out by this task or its real task. * - * @param line The line of output to log. Should not be <code>null</code>. + * @param output The output to log. Should not be <code>null</code>. */ - protected void handleFlush(String line) { + protected void handleFlush(String output) { if (realThing instanceof Task) { - ((Task) realThing).handleFlush(line); + ((Task) realThing).handleFlush(output); } else { - super.handleFlush(line); + super.handleFlush(output); } } /** * Handles error output sent to System.err by this task or its real task. * - * @param line The error line to log. Should not be <code>null</code>. + * @param output The error output to log. Should not be <code>null</code>. */ - protected void handleErrorOutput(String line) { + protected void handleErrorOutput(String output) { if (realThing instanceof Task) { - ((Task) realThing).handleErrorOutput(line); + ((Task) realThing).handleErrorOutput(output); } else { - super.handleErrorOutput(line); + super.handleErrorOutput(output); } } @@ -246,13 +246,13 @@ /** * Handles error output sent to System.err by this task or its real task. * - * @param line The error line to log. Should not be <code>null</code>. + * @param output The error output to log. Should not be <code>null</code>. */ - protected void handleErrorFlush(String line) { + protected void handleErrorFlush(String output) { if (realThing instanceof Task) { - ((Task) realThing).handleErrorOutput(line); + ((Task) realThing).handleErrorOutput(output); } else { - super.handleErrorOutput(line); + super.handleErrorOutput(output); } } 1.80 +12 -12 ant/src/main/org/apache/tools/ant/taskdefs/Ant.java Index: Ant.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Ant.java,v retrieving revision 1.79 retrieving revision 1.80 diff -u -w -u -r1.79 -r1.80 --- Ant.java 6 Jul 2003 09:57:36 -0000 1.79 +++ Ant.java 17 Jul 2003 10:20:15 -0000 1.80 @@ -263,11 +263,11 @@ * * @since Ant 1.5 */ - public void handleOutput(String line) { + public void handleOutput(String output) { if (newProject != null) { - newProject.demuxOutput(line, false); + newProject.demuxOutput(output, false); } else { - super.handleOutput(line); + super.handleOutput(output); } } @@ -290,11 +290,11 @@ * * @since Ant 1.5.2 */ - public void handleFlush(String line) { + public void handleFlush(String output) { if (newProject != null) { - newProject.demuxFlush(line, false); + newProject.demuxFlush(output, false); } else { - super.handleFlush(line); + super.handleFlush(output); } } @@ -303,11 +303,11 @@ * * @since Ant 1.5 */ - public void handleErrorOutput(String line) { + public void handleErrorOutput(String output) { if (newProject != null) { - newProject.demuxOutput(line, true); + newProject.demuxOutput(output, true); } else { - super.handleErrorOutput(line); + super.handleErrorOutput(output); } } @@ -316,11 +316,11 @@ * * @since Ant 1.5.2 */ - public void handleErrorFlush(String line) { + public void handleErrorFlush(String output) { if (newProject != null) { - newProject.demuxFlush(line, true); + newProject.demuxFlush(output, true); } else { - super.handleErrorFlush(line); + super.handleErrorFlush(output); } } 1.35 +12 -12 ant/src/main/org/apache/tools/ant/taskdefs/CallTarget.java Index: CallTarget.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/CallTarget.java,v retrieving revision 1.34 retrieving revision 1.35 diff -u -w -u -r1.34 -r1.35 --- CallTarget.java 6 Jul 2003 09:57:36 -0000 1.34 +++ CallTarget.java 17 Jul 2003 10:20:15 -0000 1.35 @@ -190,11 +190,11 @@ * * @since Ant 1.5 */ - public void handleOutput(String line) { + public void handleOutput(String output) { if (callee != null) { - callee.handleOutput(line); + callee.handleOutput(output); } else { - super.handleOutput(line); + super.handleOutput(output); } } @@ -217,11 +217,11 @@ * * @since Ant 1.5.2 */ - public void handleFlush(String line) { + public void handleFlush(String output) { if (callee != null) { - callee.handleFlush(line); + callee.handleFlush(output); } else { - super.handleFlush(line); + super.handleFlush(output); } } @@ -230,11 +230,11 @@ * * @since Ant 1.5 */ - public void handleErrorOutput(String line) { + public void handleErrorOutput(String output) { if (callee != null) { - callee.handleErrorOutput(line); + callee.handleErrorOutput(output); } else { - super.handleErrorOutput(line); + super.handleErrorOutput(output); } } @@ -243,11 +243,11 @@ * * @since Ant 1.5.2 */ - public void handleErrorFlush(String line) { + public void handleErrorFlush(String output) { if (callee != null) { - callee.handleErrorFlush(line); + callee.handleErrorFlush(output); } else { - super.handleErrorFlush(line); + super.handleErrorFlush(output); } } } 1.62 +12 -12 ant/src/main/org/apache/tools/ant/taskdefs/Java.java Index: Java.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Java.java,v retrieving revision 1.61 retrieving revision 1.62 diff -u -w -u -r1.61 -r1.62 --- Java.java 6 Jul 2003 09:57:36 -0000 1.61 +++ Java.java 17 Jul 2003 10:20:15 -0000 1.62 @@ -460,11 +460,11 @@ * * @since Ant 1.5 */ - protected void handleOutput(String line) { + protected void handleOutput(String output) { if (redirector.getOutputStream() != null) { - redirector.handleOutput(line); + redirector.handleOutput(output); } else { - super.handleOutput(line); + super.handleOutput(output); } } @@ -482,11 +482,11 @@ * * @since Ant 1.5.2 */ - protected void handleFlush(String line) { + protected void handleFlush(String output) { if (redirector.getOutputStream() != null) { - redirector.handleFlush(line); + redirector.handleFlush(output); } else { - super.handleFlush(line); + super.handleFlush(output); } } @@ -495,11 +495,11 @@ * * @since Ant 1.5 */ - protected void handleErrorOutput(String line) { + protected void handleErrorOutput(String output) { if (redirector.getErrorStream() != null) { - redirector.handleErrorOutput(line); + redirector.handleErrorOutput(output); } else { - super.handleErrorOutput(line); + super.handleErrorOutput(output); } } @@ -508,11 +508,11 @@ * * @since Ant 1.5.2 */ - protected void handleErrorFlush(String line) { + protected void handleErrorFlush(String output) { if (redirector.getErrorStream() != null) { - redirector.handleErrorFlush(line); + redirector.handleErrorFlush(output); } else { - super.handleErrorOutput(line); + super.handleErrorOutput(output); } } 1.7 +12 -12 ant/src/main/org/apache/tools/ant/taskdefs/Redirector.java Index: Redirector.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Redirector.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -u -r1.6 -r1.7 --- Redirector.java 6 Jul 2003 09:03:17 -0000 1.6 +++ Redirector.java 17 Jul 2003 10:20:15 -0000 1.7 @@ -359,13 +359,13 @@ /** * Pass output sent to System.out to specified output. * - * @param line the data to be output + * @param output the data to be output */ - protected void handleOutput(String line) { + protected void handleOutput(String output) { if (outPrintStream == null) { outPrintStream = new PrintStream(outputStream); } - outPrintStream.println(line); + outPrintStream.print(output); } /** @@ -392,38 +392,38 @@ /** * Process data due to a flush operation. * - * @param line the data being flushed. + * @param output the data being flushed. */ - protected void handleFlush(String line) { + protected void handleFlush(String output) { if (outPrintStream == null) { outPrintStream = new PrintStream(outputStream); } - outPrintStream.print(line); + outPrintStream.print(output); outPrintStream.flush(); } /** * Process error output * - * @param line the error output data. + * @param output the error output data. */ - protected void handleErrorOutput(String line) { + protected void handleErrorOutput(String output) { if (errorPrintStream == null) { errorPrintStream = new PrintStream(errorStream); } - errorPrintStream.println(line); + errorPrintStream.print(output); } /** * Handle a flush operation on the error stream * - * @param line the error information being flushed. + * @param output the error information being flushed. */ - protected void handleErrorFlush(String line) { + protected void handleErrorFlush(String output) { if (errorPrintStream == null) { errorPrintStream = new PrintStream(errorStream); } - errorPrintStream.print(line); + errorPrintStream.print(output); } /** 1.70 +17 -17 ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java Index: JUnitTask.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java,v retrieving revision 1.69 retrieving revision 1.70 diff -u -w -u -r1.69 -r1.70 --- JUnitTask.java 9 Jul 2003 13:12:24 -0000 1.69 +++ JUnitTask.java 17 Jul 2003 10:20:16 -0000 1.70 @@ -748,14 +748,14 @@ * * @since Ant 1.5 */ - protected void handleOutput(String line) { + protected void handleOutput(String output) { if (runner != null) { - runner.handleOutput(line); + runner.handleOutput(output); if (showOutput) { - super.handleOutput(line); + super.handleOutput(output); } } else { - super.handleOutput(line); + super.handleOutput(output); } } @@ -780,14 +780,14 @@ * * @since Ant 1.5.2 */ - protected void handleFlush(String line) { + protected void handleFlush(String output) { if (runner != null) { - runner.handleFlush(line); + runner.handleFlush(output); if (showOutput) { - super.handleFlush(line); + super.handleFlush(output); } } else { - super.handleFlush(line); + super.handleFlush(output); } } @@ -797,14 +797,14 @@ * * @since Ant 1.5 */ - public void handleErrorOutput(String line) { + public void handleErrorOutput(String output) { if (runner != null) { - runner.handleErrorOutput(line); + runner.handleErrorOutput(output); if (showOutput) { - super.handleErrorOutput(line); + super.handleErrorOutput(output); } } else { - super.handleErrorOutput(line); + super.handleErrorOutput(output); } } @@ -815,14 +815,14 @@ * * @since Ant 1.5.2 */ - public void handleErrorFlush(String line) { + public void handleErrorFlush(String output) { if (runner != null) { - runner.handleErrorFlush(line); + runner.handleErrorFlush(output); if (showOutput) { - super.handleErrorFlush(line); + super.handleErrorFlush(output); } } else { - super.handleErrorFlush(line); + super.handleErrorFlush(output); } } 1.37 +8 -8 ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java Index: JUnitTestRunner.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java,v retrieving revision 1.36 retrieving revision 1.37 diff -u -w -u -r1.36 -r1.37 --- JUnitTestRunner.java 14 Jul 2003 13:42:33 -0000 1.36 +++ JUnitTestRunner.java 17 Jul 2003 10:20:16 -0000 1.37 @@ -398,9 +398,9 @@ } } - protected void handleOutput(String line) { + protected void handleOutput(String output) { if (systemOut != null) { - systemOut.println(line); + systemOut.print(output); } } @@ -414,21 +414,21 @@ return -1; } - protected void handleErrorOutput(String line) { + protected void handleErrorOutput(String output) { if (systemError != null) { - systemError.println(line); + systemError.print(output); } } - protected void handleFlush(String line) { + protected void handleFlush(String output) { if (systemOut != null) { - systemOut.print(line); + systemOut.print(output); } } - protected void handleErrorFlush(String line) { + protected void handleErrorFlush(String output) { if (systemError != null) { - systemError.print(line); + systemError.print(output); } } 1.2 +15 -15 ant/src/testcases/org/apache/tools/ant/taskdefs/DefaultExcludesTest.java Index: DefaultExcludesTest.java =================================================================== RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/DefaultExcludesTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -u -r1.1 -r1.2 --- DefaultExcludesTest.java 9 May 2003 12:10:36 -0000 1.1 +++ DefaultExcludesTest.java 17 Jul 2003 10:20:16 -0000 1.2 @@ -85,7 +85,7 @@ " **/vssver.scc\n"+ " **/.svn\n"+ " **/.svn/**\n"+ - " **/.DS_Store\n"); + " **/.DS_Store"); } // adding something to the excludes' @@ -105,7 +105,7 @@ " **/.svn\n"+ " **/.svn/**\n"+ " **/.DS_Store\n"+ - " foo\n"); // foo added + " foo"); // foo added } // removing something from the defaults @@ -124,6 +124,6 @@ " **/vssver.scc\n"+ " **/.svn\n"+ " **/.svn/**\n"+ - " **/.DS_Store\n"); + " **/.DS_Store"); } } 1.7 +9 -9 ant/src/testcases/org/apache/tools/ant/taskdefs/DemuxOutputTask.java Index: DemuxOutputTask.java =================================================================== RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/DemuxOutputTask.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -w -u -r1.6 -r1.7 --- DemuxOutputTask.java 10 Feb 2003 14:14:45 -0000 1.6 +++ DemuxOutputTask.java 17 Jul 2003 10:20:16 -0000 1.7 @@ -89,6 +89,7 @@ } protected void handleOutput(String line) { + line = line.trim(); if (line.length() != 0 && !line.equals(randomOutValue)) { String message = "Received = [" + line + "], expected = [" + randomOutValue + "]"; @@ -98,6 +99,7 @@ } protected void handleErrorOutput(String line) { + line = line.trim(); if (line.length() != 0 && !line.equals(randomErrValue)) { String message = "Received = [" + line + "], expected = [" + randomErrValue + "]"; @@ -105,7 +107,5 @@ } errorReceived = true; } - - }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]