2

I have a deployment script where I move a directory to another directory. In this directory I have a symlink relative to a parent folder like this:

abc -> ../dir/file

dir/file is also in the directory which gets deployed.

I move the directory with the following lines of xml:

<move todir="${deploy.dir}">
    <fileset dir="${to.deploy}">
        <include name="**/*" />
    </fileset>
</move>

Everything gets moved but not the symlinks. The stay in the ${deploy.dir}. Why? Maybe Ant does not know how to set the new symlink (the new location)?

How can you fix this? Delete the symlink and use the symlink target to make a new one?

kenorb
  • 155,785
  • 88
  • 678
  • 743
tester
  • 3,977
  • 5
  • 39
  • 59

1 Answers1

2

Symbolic links are special files. Ant is not fully capable of handling them. Here is the note.

Ant is not symbolic link aware in moves, deletes and when recursing down a tree of directories to build up a list of files. Unexpected things can happen.

You need a custom solution , probably using readlink. Question How do I move a relative symbolic link? and answers points to additional solutions (nothing to do with ant, though)

Community
  • 1
  • 1
Jayan
  • 18,003
  • 15
  • 89
  • 143
  • "unexpected things can happen" does not sound very nice to me for a deployment script. That could also mean, it f*cks up everything and deletes everything? :-) But nevertheless, I found out that I can do it with the symlink target. I don't know why ant can handle symlinks inside the symlink target, but not the move target... – tester Jul 09 '13 at 05:38
  • @tester : java does not support symlinks directly. ant works around by comparing paths (canonical and absolute). The note says this is error prone on non-unix platforms. – Jayan Jul 09 '13 at 09:14