antphing

Phing alternative for fixlastline from ant


I'm rewriting build.xml file from Ant to Phing and everything goes fine with one exception. I need to add new line at the end of each appended file but I can't find any alternative for fixlastline="true".

In Ant it was

 <concat destfile="${libraryFilePrefix}.js" fixlastline="yes">
     <!-- many filesets -->
 </concat>

In Phing it's like

 <append destfile="${libraryFilePrefix}.js">
     <!-- many filesets -->
 </append>

Is there any attribute that works like fixlastline or maybe I need to find another way to achieve this?


Solution

  • I believe, one of the approaches (and possibly the only one) is applying replaceregexp filter on each fileset. You only need to apply filterchain at the beginning and it will do the job for each fileset, like this:

    <append destfile="${libraryFilePrefix}.js">
        <filterchain>
            <replaceregexp>
                <regexp pattern="([^\n])$" replace="$1${line.separator}" ignoreCase="true"/>
            </replaceregexp>
        </filterchain>
    
        <!-- many filesets -->
    </append>