--- Jon Schewe <[EMAIL PROTECTED]> wrote: > My build script currently has a task in it that copies files from one > directory to another changing the extension, using a file mapper. This > works great. Now the problem I have is that if I delete a file in the > source directory I'd like to have ant delete the file in the destination > directory the next time it builds, but only for files that are missing > [...] > Has someone already done this, or do I need to write my own task?
Didn't write you a task, since it's faster for me to do it in Javascript (anything to avoid doin' the dishes :) <property name="src.dir" location="src"/> <property name="dest.dir" location="dest"/> <target name="sync"> <fileset dir="${dest.dir}" id="chkfiles"> <include name="**/*.ship"/> </fileset> <pathconvert pathsep="," property="chkfiles" refid="chkfiles"> <map from="${dest.dir}" to=""/> </pathconvert> <script language="javascript"> <![CDATA[ importClass(java.io.File); importClass(java.util.StringTokenizer); var srcdir = projname.getProperty("src.dir"); var destdir = projname.getProperty("dest.dir"); var files = projname.getProperty("chkfiles"); var filesep = projname.getProperty("file.separator"); var st = new StringTokenizer(files, " ,"); while (st.hasMoreTokens()) { var filename = st.nextToken(); var pos = filename.indexOf('.'); chkfilename = filename.substring(0, pos); chkfilename = srcdir.concat(chkfilename).concat(".orig"); var chkfile = new File(chkfilename); if(!chkfile.exists()) { filename = destdir.concat(filename); showit = projname.createTask("echo"); showit.setMessage( "Deleting leftover file: " + filename ); showit.execute(); } } ]]> </script> </target> $ ant sync sync: [echo] Deleting leftover file: C:\TEMP\dest\dir1\c\foo.ship [echo] Deleting leftover file: C:\TEMP\dest\dir2\b\baz.ship (Change the extensions to what yours really are, and change the "showit"s to deletes.) Diane ===== ([EMAIL PROTECTED]) __________________________________________________ Do You Yahoo!? Yahoo! Games - play chess, backgammon, pool and more http://games.yahoo.com/ -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>