tags:

views:

23

answers:

1

I'm using ant 1.6.2... I want to supply parameters to StripLineBreaks (essentially, I want to remove any \r in the text, but not \n.

So, I have tried (in the build.xml file)

<copy file="a" todir="/tmp/work>
   <filterchain>
      <filterreader classname="org.apache.tools.ant.filters.StripLineBreaks>
         <param name="linebreaks" value="\r"/>
      </filterreader>
   </filterchain>
</copy>

Using the above strips out all letter "r" (for example, "jar" becomes "ja")

I have tried "\r", "\\r", and "\\r"

I cannot upgrade ant to a later version.

Help is appreciated.

+1  A: 

To answer the question as written, StripLineBreaks uses the value from XML literally, so specifying "\r" just means \ and r. Instead, encode the CR using an XML character reference:

<copy file="a" todir="/tmp/work">
  <filterreader classname="org.apache.tools.ant.filters.StripLineBreaks">
    <param name="linebreaks" value="&#13;"/>
  </filterreader>
</copy>

Of course, it's easier to just use the fixcrlf task directly:

<fixcrlf file="a.xml" destdir="/tmp/work" eol="lf"/>
bkail
The fixcrlf task does not exist in ant 1.6.2
Richard
Other comment: the documentation uses \r\n is the default string; many thanks for the assistance!
Richard
According to the javadoc, FixCRLF has existed since Ant 1.1. It is not available as a filter until 1.7. That said, if the XML character reference solved your problem, please accept the answer.
bkail