Making the delete task behave like /bin/rm -rf vis-a-vis symlinks to directories

View: New views
6 Messages — Rating Filter:   Alert me  

Making the delete task behave like /bin/rm -rf vis-a-vis symlinks to directories

by jscripter :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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?

Re: Making the delete task behave like /bin/rm -rf vis-a-vis symlinks to directories

by Scot P. Floess-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Have you looked at the symlink task?

http://ant.apache.org/manual/OptionalTasks/symlink.html

On Mon, 22 Jun 2009, 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: http://www.nabble.com/Making-the-delete-task-behave-like--bin-rm--rf-vis-a-vis-symlinks-to-directories-tp24154698p24154698.html
> Sent from the Ant - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>
>

Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087 (Home)
919-890-8117 (Work)

Chief Architect JPlate   http://sourceforge.net/projects/jplate
Chief Architect JavaPIM  http://sourceforge.net/projects/javapim

Architect Keros          http://sourceforge.net/projects/keros

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


Re: Making the delete task behave like /bin/rm -rf vis-a-vis symlinks to directories

by jscripter :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The main problem with this is that I don't want to keep track of which symlinks to delete.
The tree I am deleting may have lots of symlinks.

I realize that Java doesn't know about symlinks and that Ant uses a heuristic to determine if a file object is a symlink, but is there a way to create a fileset of everything that looks like a symlink?


Scot P. Floess-2 wrote:
Have you looked at the symlink task?

http://ant.apache.org/manual/OptionalTasks/symlink.html

On Mon, 22 Jun 2009, 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: http://www.nabble.com/Making-the-delete-task-behave-like--bin-rm--rf-vis-a-vis-symlinks-to-directories-tp24154698p24154698.html
> Sent from the Ant - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087 (Home)
919-890-8117 (Work)

Chief Architect JPlate   http://sourceforge.net/projects/jplate
Chief Architect JavaPIM  http://sourceforge.net/projects/javapim

Architect Keros          http://sourceforge.net/projects/keros

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

Re: Making the delete task behave like /bin/rm -rf vis-a-vis symlinks to directories

by David Weintraub :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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<pc88mxer@...> 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: http://www.nabble.com/Making-the-delete-task-behave-like--bin-rm--rf-vis-a-vis-symlinks-to-directories-tp24154698p24154698.html
> Sent from the Ant - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@...
> For additional commands, e-mail: user-help@...
>
>



--
David Weintraub
qazwart@...

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


Re: Making the delete task behave like /bin/rm -rf vis-a-vis symlinks to directories

by Andy Stevens-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 26/06/2009, jscripter <pc88mxer@...> wrote:
>
>  The main problem with this is that I don't want to keep track of which
>  symlinks to delete.
>  The tree I am deleting may have lots of symlinks.
>
>  I realize that Java doesn't know about symlinks and that Ant uses a
>  heuristic to determine if a file object is a symlink, but is there a way to
>  create a fileset of everything that looks like a symlink?

Just a thought - is there a way to build a fileset from the output of
an <exec> task?  If so, how about using that to call "find . -type l
-print" in the relevant directory?


Andy
--
http://pseudoq.sourceforge.net/

>
>  Scot P. Floess-2 wrote:
>  >
>  >
>  > Have you looked at the symlink task?
>  >
>  > http://ant.apache.org/manual/OptionalTasks/symlink.html
>  >
>  > On Mon, 22 Jun 2009, 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?

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


Re: Making the delete task behave like /bin/rm -rf vis-a-vis symlinks to directories

by Francis Galiegue-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Jun 30, 2009 at 23:19, Andy
Stevens<insomniacpenguin@...> wrote:

> On 26/06/2009, jscripter <pc88mxer@...> wrote:
>>
>>  The main problem with this is that I don't want to keep track of which
>>  symlinks to delete.
>>  The tree I am deleting may have lots of symlinks.
>>
>>  I realize that Java doesn't know about symlinks and that Ant uses a
>>  heuristic to determine if a file object is a symlink, but is there a way to
>>  create a fileset of everything that looks like a symlink?
>
> Just a thought - is there a way to build a fileset from the output of
> an <exec> task?  If so, how about using that to call "find . -type l
> -print" in the relevant directory?
>
>

<exec output="/path/to/symlink/list" executable="/usr/bin/find">
    <arg value="/the/dir"/>
    <arg value="-type"/>
    <arg value="l"/>
</exec>

<fileset id="victims" dir="/the/dir">
    <includesfile name="/path/to/symlink/list>
</fileset>


--

Francis Galiegue
ONE2TEAM
Ingénieur système
Mob : +33 (0) 683 877 875
Tel : +33 (0) 178 945 552
fge@...
40 avenue Raymond Poincaré
75116 Paris

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