--- Stefan Kost <[EMAIL PROTECTED]> wrote: > I waited for ant-1.5b1 but miss the foreach. At least there is no > documentation for it. I check the binary-jar to see if the is a class, > named like this and there ins't one. > Can you enlighten me on this ?
The <foreach> task is part of the ant-contrib project on Sourceforge: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/ant-contrib/ant-contrib/src/net/sf/antcontrib/logic As an example of using it for your case: <fileset id="xmlfiles" dir="${sourcePath}"> <include name="**/ejb-jar.xml"/> </fileset> <target name="xmlfs"> <echo file="${basepath}/xmlfiles.xml"><![CDATA[ <files>]]></echo> <pathconvert property="xmlfiles" pathsep="," refid="xmlfiles"> <map from="${sourcePath}${file.separator}" to=""/> </pathconvert> <foreach list="${xmlfiles}" target="genXmlFS" param="xmlfile"/> <echo file="${basepath}/xmlfiles.xml" append="true"><![CDATA[ </files> ]]></echo> </target> <target name="genXmlFS"> <echo file="${basepath}/xmlfiles.xml" append="true"><![CDATA[ <file>${xmlfile}</file>]]></echo> </target> And just for completeness, since I also mentioned doing it with <script>: <target name="xmlfs"> <delete file="xmlfiles.xml"/> <pathconvert property="xmlfiles" pathsep="," refid="xmlfiles"> <map from="${sourcePath}${file.separator}" to=""/> </pathconvert> <script language="javascript"> <![CDATA[ importClass(java.io.File); importClass(java.io.FileWriter); importClass(java.util.StringTokenizer); outfile = new File("xmlfiles.xml"); var append = true; var lsep = project.getProperty("line.separator"); out = new FileWriter(outfile, append); files = project.getProperty("xmlfiles"); out.write("<files>" + lsep); st = new StringTokenizer(files, " ,"); while (st.hasMoreTokens()) { file = st.nextToken(); out.write(" <file>" + file + "</file>" + lsep); } out.write("</files>" + lsep); out.close(); ]]> </script> </target> Diane ===== ([EMAIL PROTECTED]) __________________________________________________ Do You Yahoo!? Yahoo! Health - your guide to health and wellness http://health.yahoo.com -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
