I would like to set up an ant task to delete all .class and .jar files from the same directory the build.xml file is, including nonsense.class which is in the same directory as the build.xml file. So I've set up the following build.xml file for ant 1.9.0 as follows:
<?xml version="1.0"?>
<project name="HelloWorld" default="deploy">
<!-- ... -->
<target name="clean">
<delete file="nonsense.class" />
<delete file="*.class" />
<delete file="*.jar" />
</target>
</project>
When I execute it nonsense.class is removed but none of the other .class or .jar files. What am I doing wrong?
You need to use a fileset to delete more than one file:
<target name="clean">
<delete file="nonsense.class" />
<delete>
<fileset dir=".">
<include name="*.class"/>
<include name="*.jar"/>
</fileset>
</delete>
</target>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With