ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Diane Holt <hol...@yahoo.com>
Subject Re: How do I delete files using a mapper?
Date Fri, 24 May 2002 19:43:19 GMT
--- Chris Bailey <chris@codeintensity.com> wrote:
> I have a task that turns .xml files into .java files, that reside in the
> same source dir as the rest of my .java files.  But, I want to be able
> to "clean" those generated java files.

  <target name="clean.generated.java">
    <fileset dir="${src}" id="xmlfiles" includes="**/*.xml"/>
    <pathconvert pathsep="," property="xmlfiles" refid="xmlfiles"/>
    <script language="javascript"> <![CDATA[
      importClass(java.io.File);
      importClass(java.util.StringTokenizer);
      var files = projname.getProperty("xmlfiles");
      var st = new StringTokenizer(files, " ,");
      while (st.hasMoreTokens()) {
        var filename = st.nextToken();
        var pos = filename.lastIndexOf('.');
        var chkfile = new File(filename.substring(0, pos) + ".java");
        if(chkfile.exists()) {
          showit = projname.createTask("echo");
          showit.setMessage( "Deleting generated file: " + chkfile );
          showit.execute();
        }
      }
      ]]>
    </script>
  </target>

(Change it to do delete instead of echo -- but I'd run it as is first to
make sure it's doing the files you want.)

Diane

=====
(holtdl@yahoo.com)



__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com

--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message