Doron Shai
Doron Shai

Reputation: 698

Can't delete a file using Ant

I want to use ANT script to delete a file.

For some reason the following script gives me the following message:

BUILD SUCCESSFUL
Total time: 0 seconds

The script I am running is:

<?xml version="1.0"?> 
<project name="UpdateFlag"> 
    <target name="deleteFlag">  
        <delete file="/state/update.flag" failonerror="true"/>      
    </target>
</project>

Please assist.

Upvotes: 2

Views: 3171

Answers (1)

David W.
David W.

Reputation: 107080

<delete file="/state/update.flag" failonerror="true"/>

Will delete the file that's is in the state directory that's on the root of your directory structure. In Unix, it would be /state/update.flag, and in Windows (on the C: drive), it would be C:\state\update.flag. Is this where the file is located?

When in doubt, run Ant with the -d and -v switches. This will print out lots of useful information (and tons of useless garbage). For example, did your delete task find a file to delete? If the file isn't there, the <delete> task won't fail.

I have a funny feeling that you actually meant to do:

 <delete file="${basedir}/state/update.flag"
    failonerror="true"/>

Upvotes: 4

Related Questions