File1.txt(SVN可怕结构)
abcBIN abcBIN/fdPro ...so on
File2.txt(Linux结构)
apps/xxx/yyy/bin/abc apps/xxx/yyy/bin/abc/fdpro ...so on
我需要将abcBIN文件dir复制到apps / xxx / yyy / bin / abc等等.一对一映射.
<project xmlns:ac="antlib:net.sf.antcontrib"> <taskdef resource="net/sf/antcontrib/antcontrib.properties"> <classpath> <pathelement location="path-to-ant-contrib.jar"/> </classpath> </taskdef> <loadfile property="file1" srcfile="File1.txt"/> <loadfile property="file2" srcfile="File2.txt"/> <ac:for param="i" list="${file1}"> <ac:for param="j" list="${file2}"> <sequential> <echo>@{i}@{j}</echo> <echo>copying....</echo> <property name="src.dir" value="/home/name/svn_repo/dir" /> <property name="dest.dir" value="/home/name/mapp" /> <copy todir="${dest.dir}/@{j}"> <fileset dir="${src.dir}/@{i}"> </fileset> </copy> </sequential> </ac:for> </ac:for> </project>
虽然不行.
我收到一个错误:
ac:for doesn't support the nested "for" element
我不能使用UNIX shell或Perl.它必须在Ant中完成.
如果您对Ant中的嵌套循环有任何了解,请告诉我.
@PulakAgrawal:我将两个文本文件合并为一个使用冒号作为行分隔符,魔法开始了:)例如src路径:dest路径
<loadfile property="allfiles" srcFile="mapping"/> <ac:for list="${allfiles}" param="line" delimiter="${line.separator}"> <ac:sequential> <ac:propertyregex property="from" input="@{line}" regexp="(.*):(.*)" select="\1" override="true"/> <ac:propertyregex property="to" input="@{line}" regexp="(.*):(.*)" select="\2" override="true"/> <echo>Copying dir ${from} to ${to} ...</echo> <property name="src.dir" value="." /> <property name="dest.dir" value="." /> <copy todir="${dest.dir}/${to}"> <fileset dir="${src.dir}/${from}"> </fileset> </copy> </ac:sequential> </ac:for>
精彩评论