2
我有2组属性。一个是文件列表,另一个是dirs列表。这样通过阅读属性文件蚂蚁复制文件
文件file1的=,file2的,file3的,file4将
destination.dir = DIR1,DIR2,DIR3,dir4
这些2种性质在build.properties定义。
我想复制file1到dir1,file2到dir2等等。
如何在蚂蚁中实现这一点?
感谢
我有2组属性。一个是文件列表,另一个是dirs列表。这样通过阅读属性文件蚂蚁复制文件
文件file1的=,file2的,file3的,file4将
destination.dir = DIR1,DIR2,DIR3,dir4
这些2种性质在build.properties定义。
我想复制file1到dir1,file2到dir2等等。
如何在蚂蚁中实现这一点?
感谢
使用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)的红宝石,JavaScript的..脚本任务中