Trong tệp build.xml của mình, tôi muốn làm tương đương với cmd1 | xargs cmd2
(và cũng lưu trữ danh sách tệp từ cmd1
vào biến ${dependencies}
), trong đó cmd1
cung cấp danh sách đường dẫn được phân tách bằng dòng mới. Tôi không thể tìm ra cách để làm điều này trong Ant.Làm thế nào để thay thế dòng mới trong ant trong outputfilterchain?
<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>