在我的build.xml中,我想要執行cmd1 | xargs cmd2
的等效操作(並將cmd1
中的文件列表存儲到變量${dependencies}
中),其中cmd1
給出了一個換行符分隔的路徑列表。我無法弄清楚如何在Ant中做到這一點。如何在輸出過濾鏈中替換ant中的換行符?
<project default="main">
<target name="main">
<exec executable="echo"
outputproperty="dependencies">
<arg value="closure/a.js
closure/b.js
closure/c.js"/>
<redirector>
<outputfilterchain>
<replacestring from="${line.separator}" to=" "/>
<!-- None of these do anything either:
<replacestring from="\n" to=" "/>
<replacestring from="
" to=" "/>
<replaceregex pattern="
" replace=" " flags="m"/>
<replaceregex pattern="\n" replace=" " flags="m"/>
<replaceregex pattern="${line.separator}" replace=" " flags="m"/>
-->
</outputfilterchain>
</redirector>
</exec>
<!-- Later, I need to use each file from ${dependencies} as an argument
to a command. -->
<exec executable="echo">
<!--This should turn into 3 arguments, not 1 with newlines.-->
<arg line="${dependencies}"/>
</exec>
</target>
</project>