来自蚂蚁的固定线的替代品

时间:2013-10-21 13:39:57

标签: ant phing

我正在将build.xml文件从Ant重写为Phing,一切顺利,只有一个例外。 我需要在每个附加文件的末尾添加新行,但我找不到fixlastline="true"的任何替代方法。

在Ant中它是

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

Phing就像

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

是否存在类似fixlastline的属性,或者我需要找到另一种方法来实现这一目标?

2 个答案:

答案 0 :(得分:1)

我相信,其中一种方法(可能是唯一的方法)是在每个文件集上应用 replaceregexp 过滤器。您只需在开头应用过滤链,它就会为每个fileset执行此任务,如下所示:

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

    <!-- many filesets -->
</append>

答案 1 :(得分:1)

从Phing 3.x开始,AppendTask知道fixlastline属性。您提供的Ant脚本现在可以按预期运行

    <project name="concat-supports-fixlastline" default="concat-fixed-lastline" basedir=".">
        <target name="concat-fixed-lastline">            
            <concat destfile="${libraryFilePrefix}.js" fixlastline="yes">
                <!-- many filesets -->
            </concat>
        </target>
    </project>