无法使用ANT脚本删除符号链接

时间:2012-10-08 05:38:32

标签: ant symlink delete-file

我正在尝试使用以下行删除符号链接:

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

它抛出错误说:

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

/ directory / where / symlink / points应该是只读的。有没有办法可以删除符号链接?

1 个答案:

答案 0 :(得分:7)

可以使用<delete> Ant任务删除指向只读资源的符号链接。

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

来自<delete> Ant任务文档:

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