user1182504
user1182504

Reputation:

How to delete a symlink using Ant?

I am trying to delete a symlink in ant script using the below line :

<symlink action="delete" link="/path/of/link/symlink"/>

But it is showing an error:

Could not create tempfile in /directory/where/symlink/points

The /directory/where/symlink/points is supposed to be read-only.

Is there a way in which I could just delete the symlink and not mess up other things? It's a part of a big script.

Upvotes: 1

Views: 1668

Answers (1)

Riju Mahna
Riju Mahna

Reputation: 6926

Symlinks pointing to read-only resources may be deleted using the <delete> Ant task.

<target name="delete-symlink">
<delete file="/path/of/link/symlink" followsymlinks="false"
      removenotfollowedsymlinks="true" />
</target>

And this is from the delete Ant task documentation:

removeNotFollowedSymlinks  Whether symbolic links (not the files/directories 
                       they link to) should be removed if they haven't been 
                       followed because followSymlinks was false or the 
                       maximum number of symbolic links was too big. Since 
                       Ant 1.8.0

Hope it works.

Upvotes: 3

Related Questions