Text manipulation in ant

ant

Given an ant fileset, I need to perform some sed-like manipulations on it, condense it to a multi-line string (with effectively one line per file), and output the result to a text file.

What ant task am I looking for?

Best Solution

Looks like you need a conbination of tasks:

This strips the '\r' and '\n' characters of a file and load it to a propertie:

<loadfile srcfile="${src.file}" property="${src.file.contents}">
  <filterchain>
    <filterreader classname="org.apache.tools.ant.filters.StripLineBreaks"/>
  </filterchain>
</loadfile>

After loading the files concatenate them to another one:

<concat destfile="final.txt">
  ...
</concat>

Inside concat use a propertyset to reference the files content:

<propertyset id="properties-starting-with-bar">
  <propertyref prefix="src.file"/>
</propertyset>
Related Question