git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1573617 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -111,6 +111,13 @@ Other changes: | |||
| * changes to DOMElementWriter to make OutOfMemoryErrors less likely. | |||
| Bugzilla Report 54147 | |||
| * <redirector> has a new attribute binaryOutput that prevents Ant | |||
| from splitting the output into lines. This prevents binary output | |||
| from being corrupted but may lead to error and normal output being | |||
| mixed up. | |||
| Bugzilla Report 55667 | |||
| Bugzilla Report 56156 | |||
| Changes from Ant 1.9.2 TO Ant 1.9.3 | |||
| =================================== | |||
| @@ -136,6 +136,16 @@ source (input) and destination (output/error) files. <em>Since Apache Ant 1.6.2 | |||
| </td> | |||
| <td align="center" valign="top">No, default is <code>true</code></td> | |||
| </tr> | |||
| <tr> | |||
| <td valign="top">binaryOutput</td> | |||
| <td valign="top">When set to true Ant will not try to split the | |||
| output into lines - which it will usually do in order to separate | |||
| error from normal output. This setting will not prevent binary | |||
| output from getting corrupted if you also specify filter chains. | |||
| <i>Since Ant 1.9.4</i>. | |||
| </td> | |||
| <td align="center" valign="top">No, default is <code>false</code></td> | |||
| </tr> | |||
| </table> | |||
| <h3>Parameters specified as nested elements</h3> | |||
| <h4>inputmapper</h4> | |||
| @@ -192,6 +192,9 @@ public class Redirector { | |||
| /** Mutex for err */ | |||
| private Object errMutex = new Object(); | |||
| /** Is the output binary or can we safely split it into lines? */ | |||
| private boolean outputIsBinary = false; | |||
| /** | |||
| * Create a redirector instance for the given task | |||
| * | |||
| @@ -523,6 +526,18 @@ public class Redirector { | |||
| } | |||
| } | |||
| /** | |||
| * Whether to consider the output created by the process binary. | |||
| * | |||
| * <p>Binary output will not be split into lines which may make | |||
| * error and normal output look mixed up when they get written to | |||
| * the same stream.</p> | |||
| * @since 1.9.4 | |||
| */ | |||
| public void setBinaryOutput(boolean b) { | |||
| outputIsBinary = b; | |||
| } | |||
| /** | |||
| * Set a property from a ByteArrayOutputStream | |||
| * | |||
| @@ -722,8 +737,12 @@ public class Redirector { | |||
| OutputStreamFunneler funneler = new OutputStreamFunneler( | |||
| outputStream, funnelTimeout); | |||
| try { | |||
| outputStream = new LineOrientedOutputStreamRedirector(funneler.getFunnelInstance()); | |||
| errorStream = new LineOrientedOutputStreamRedirector(funneler.getFunnelInstance()); | |||
| outputStream = funneler.getFunnelInstance(); | |||
| errorStream = funneler.getFunnelInstance(); | |||
| if (!outputIsBinary) { | |||
| outputStream = new LineOrientedOutputStreamRedirector(outputStream); | |||
| errorStream = new LineOrientedOutputStreamRedirector(errorStream); | |||
| } | |||
| } catch (IOException eyeOhEx) { | |||
| throw new BuildException( | |||
| "error splitting output/error streams", eyeOhEx); | |||
| @@ -104,6 +104,9 @@ public class RedirectorElement extends DataType { | |||
| /** whether to log the inputstring */ | |||
| private Boolean logInputString; | |||
| /** Is the output binary or can we safely split it into lines? */ | |||
| private boolean outputIsBinary = false; | |||
| /** | |||
| * Add the input file mapper. | |||
| * @param inputMapper <code>Mapper</code>. | |||
| @@ -426,6 +429,18 @@ public class RedirectorElement extends DataType { | |||
| return result; | |||
| } | |||
| /** | |||
| * Whether to consider the output created by the process binary. | |||
| * | |||
| * <p>Binary output will not be split into lines which may make | |||
| * error and normal output look mixed up when they get written to | |||
| * the same stream.</p> | |||
| * @since 1.9.4 | |||
| */ | |||
| public void setBinaryOutput(boolean b) { | |||
| outputIsBinary = b; | |||
| } | |||
| /** | |||
| * Configure the specified <code>Redirector</code>. | |||
| * @param redirector <code>Redirector</code>. | |||
| @@ -530,6 +545,7 @@ public class RedirectorElement extends DataType { | |||
| if (errorEncoding != null) { | |||
| redirector.setErrorEncoding(errorEncoding); | |||
| } | |||
| redirector.setBinaryOutput(outputIsBinary); | |||
| } | |||
| /** | |||
| @@ -678,4 +678,33 @@ public class Hello { | |||
| <au:assertLogDoesntContain text="Hello 20"/> | |||
| </target> | |||
| <target name="test-output-is-split-into-lines" if="cat.can.run" depends="setUp"> | |||
| <echo file="${input}/redirector.in">1
2
3</echo> | |||
| <echo file="${output}/expected">1${line.separator}2${line.separator}3</echo> | |||
| <exec executable="cat"> | |||
| <redirector output="${output}/redirector.out" | |||
| input="${input}/redirector.in"/> | |||
| </exec> | |||
| <au:assertTrue> | |||
| <resourcesmatch astext="true"> | |||
| <file file="${output}/redirector.out" /> | |||
| <file file="${output}/expected" /> | |||
| </resourcesmatch> | |||
| </au:assertTrue> | |||
| </target> | |||
| <target name="test-binary-output-is-not-split-into-lines" if="cat.can.run" depends="setUp"> | |||
| <echo file="${input}/redirector.in">1
2
3</echo> | |||
| <exec executable="cat"> | |||
| <redirector output="${output}/redirector.out" binaryOutput="true" | |||
| input="${input}/redirector.in"/> | |||
| </exec> | |||
| <au:assertTrue> | |||
| <resourcesmatch astext="true"> | |||
| <file file="${output}/redirector.out" /> | |||
| <file file="${input}/redirector.in" /> | |||
| </resourcesmatch> | |||
| </au:assertTrue> | |||
| </target> | |||
| </project> | |||