It is unclear how deep in the directory tree you want to delete .java files. I will provide ways to do both.
Complete recursive deletion
Recursively deletes all .java files anywhere in the provided destination directory.
<delete> <fileset dir="${basedir}/path/to/target/directory" includes="**/*.java"/> </delete>
Only in the target directory and its immediate child directories
Deletes .java files in the specified target directory and in any directories that are direct children of the target directory, but no more.
<delete> <fileset dir="${basedir}/path/to/target/directory" includes="*.java,*/*.java"/> </delete>
See the documentation for the uninstall task for additional options.
Be careful . If you put the wrong directory in your target directory, you can delete those things that you do not want. Consider creating paths to the target directory relative to the assembly file or ${basedir} .
source share