ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Weintraub <>
Subject Re: Making the delete task behave like /bin/rm -rf vis-a-vis symlinks to directories
Date Fri, 26 Jun 2009 18:21:45 GMT
I played around with this for a while, and I couldn't do this with the
<delete> task. I also checked and symlinks aren't defined in any
resource collection either.

The problem is that Java doesn't have the concept of the symlink. If
you read the information about the optional <symlink> task, it tells
you that <symlink> uses a hack that might not work on non-Unix systems
to figure out what the symlinks are.

The only thing I can think of is a rather complex piece of strategy:

1). Use the <symlink> task to create a directory containing the symlinks
2). Now use the replace <replaceRegexp> task to remove "=.*" from each
line in the file. This will give you a list of symbolic links.
3). Now use the AntContrib <for> or <foreach> to loop through the file
and remove this particular symlink with the <symlink> task.

Of course, you could also simply use the <exec executable="rm"> by this point.

On Mon, Jun 22, 2009 at 4:22 PM, jscripter<> wrote:
> I am using this target definition to remove all the files under ${TOP} which
> contains some symlinks to other directories:
>    <target name="clean">
>        <delete includeEmptyDirs="true" failonerror="false">
>            <fileset dir="${TOP}" followsymlinks="false"/>
>        </delete>
>    </target>
> However, I've noticed that delete is not deleting the symlinks.
> I'd like to get the same results as /bin/rm -rf under Unix, i.e. the
> symlinks are deleted but not followed. Is there a way to do that with the
> delete task?
> --
> View this message in context:
> Sent from the Ant - Users mailing list archive at
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

David Weintraub

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message