File Ant通过读取属性文件复制文件
我有两组属性,一组是文件列表,另一组是目录列表。像这样 Files=file1、file2、file3、file4 destination.dir=dir1,dir2,dir3,dir4 这两个属性在build.properties中定义 我想将file1复制到dir1,file2复制到dir2,依此类推 如何在ant中实现这一点File Ant通过读取属性文件复制文件,file,ant,properties,copy,File,Ant,Properties,Copy,我有两组属性,一组是文件列表,另一组是目录列表。像这样 Files=file1、file2、file3、file4 destination.dir=dir1,dir2,dir3,dir4 这两个属性在build.properties中定义 我想将file1复制到dir1,file2复制到dir2,依此类推 如何在ant中实现这一点 感谢使用Ant插件的解决方案 文件::=替换('${files}','''.{split('${files}',',')[0]},') 或者使用一些脚本语言,如g
感谢使用Ant插件的解决方案
文件::=替换('${files}','''.{split('${files}',',')[0]},')
或者使用一些脚本语言,如groovy、beanshell、(j)ruby、javascript。。脚本内任务
<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>