ant delete task with wildcard not working

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?


您需要使用文件集来删除多个文件:

  <target name="clean">
    <delete file="nonsense.class" />
    <delete>
      <fileset dir=".">
        <include name="*.class"/>
        <include name="*.jar"/>
      </fileset>
    </delete>
  </target>
链接地址: http://www.djcxy.com/p/44392.html

上一篇: 在Java中修改默认类加载器的行为

下一篇: 蚂蚁删除通配符不工作的任务