Ant nested loop

I have two txt files: File1.txt - contains a list of src dir; and File2.txt - contains a list of dest dir. I need to make a copy using a loop from src dir to dest dir.

File1.txt (SVN structure structure)

abcBIN abcBIN/fdPro ...so on 

File2.txt (LINUX structure)

 apps/xxx/yyy/bin/abc apps/xxx/yyy/bin/abc/fdpro ...so on 

I need to copy the file abcBIN files to applications / xxx / yyy / bin / abc, etc. From one to one.

 <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> 

He does not work.

I get an error message:

 ac:for doesn't support the nested "for" element 

I cannot use the UNIX or Perl shell. This must be done in Ant.

Please let me know if you have a better idea of ​​a nested loop in Ant.

+4
source share
1 answer

@PulakAgrawal: I combined the two text files into one using a colon as a line separator, and the magic started :)

eg. src path: dest path

  <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> 
+2
source

All Articles