ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Ludwig <mil...@gmx.de>
Subject Delete task eagerness on Windows
Date Sun, 19 Apr 2009 10:00:28 GMT
Ant (version 1.7.1), or more precisely: Ant's Delete task merrily
deletes write-protected files and directories on Windows XP that cannot
be deleted using the DEL (without /f) and RD commands from the cmd.exe
console.

In cmd.exe, type:

more > ant-delete.xml
<project name="DeleteTest" basedir="C:/temp/DeleteTest"
default="create">
        <property name="test.dir" location="abc"/>
        <property name="test.file" location="abc.txt"/>
        <target name="create">
                <echo message="Moin" file="${test.file}"/>
                <mkdir dir="${test.dir}"/>
        </target>
        <target name="clean">
                <delete file="${test.file}"/>
                <delete dir="${test.dir}"/>
        </target>
</project>
^Z (hit <F6>)

rem Create project folder
md C:\temp\DeleteTest

rem Create file and folder
ant -f ant-delete.xml

rem Set write-protection
attrib +R C:\temp\DeleteTest
attrib +R C:\temp\DeleteTest\abc
attrib +R C:\temp\DeleteTest\abc.txt

rem Try to delete using RD and DEL, which fails
rd C:\temp\DeleteTest\abc
del C:\temp\DeleteTest\abc.txt

rem But Ant unscrupulously cleans up ...
ant -f ant-delete.xml clean

Now abc and abc.txt are gone, despite being write-protected. I find it
difficult to consider this a feature. Is this behaviour intentional?

Note that as a consequence, <delete dir="${some.dir}"/> on Windows means
to recursively and unconditionally remove ${some.dir}, which even on
UNIX would require the user to spell out `rm -rf'.

Note that on UNIX, a `chmod a-w' on the project folder prevents Ant
from deleting file and folder.

Michael

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message