我有两组属性。一个是文件列表,另一个是目录列表。这样的
=文件file1、file2 file3, file4
destination.dir = dir1 dir2, dir3, dir4
这两个属性定义在build.properties.
我想复制file1到dir1,file2到dir2,等等
我如何在ant中实现这一点?
谢谢
Ant插件的解决方案Flaka
<project xmlns:fl="antlib:it.haefelinger.flaka">
<!-- make standard ant tasks like copy understand EL expressions -->
<fl:install-property-handler />
<property name="files" value="/some/path/file1,/some/path/file2,/some/path/file3,/some/path/file4"/>
<property name="destination.dir" value="/some/otherpath/dir1,/some/otherpath/dir2,/some/otherpath/dir3,/some/otherpath/dir4"/>
<!-- iterate over the csv property destination.dir -->
<fl:for var="dir" in="split('${destination.dir}', ',')">
<!-- copy the first item from csv property ${files} -->
<copy file="#{split('${files}',',')[0]}" todir="#{dir}" verbose="true"/>
<!--
afterwards delete this file item from csv property ${files}, means
editing and overwriting ${files} for the next loop
-->
<fl:let>files ::= replace('${files}', '' , '#{split('${files}',',')[0]},?' )</fl:let>
</fl:for>
</project>
可以选择使用一些脚本语言,如groovy, beanshell, (j)ruby, javascript…脚本任务