java - Recursively deleting all files of one type using Ant -


In an entry build script, how do I delete all * .java files in the same directory? Can its subdirectory?

It is not quite clear how deep in the directory tree you want to delete .java I will provide both ways to do the files.

Delete completed recurrence

Anywhere under provided. Java deletes the target directory.

  & lt; Remove & gt; & Lt; Fileset dir = "$ {baseir} / path / to / target / directory" includes = "** / * .java" /> & Lt; / Delete & gt;   

Within the target directory and its immediate child directories

deleted .java files in the specified target Directory, and any directory that has children of the immediate target directory, but not further.

  & lt; Delete & gt; & Lt; Fileset dir = "$ {baseir} / path / to / target / directory" includes = "* .java, * / * .java" /> & Lt; / Delete & gt;   

For additional options, see for removing a task.

Be careful - If you enter the wrong directory for your target directory, you can remove the things you do not want in the way of your target dior relative to the build file Consider making or $ {baseir} .

Comments