Bug 64053 - Move Task doesn't work with symlinked directories
Summary: Move Task doesn't work with symlinked directories
Status: NEW
Alias: None
Product: Ant
Classification: Unclassified
Component: Core tasks (show other bugs)
Version: 1.10.6
Hardware: PC Linux
: P2 major (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-06 17:22 UTC by Marc Streckfuß
Modified: 2020-01-06 17:22 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Streckfuß 2020-01-06 17:22:15 UTC
Since I am not that familiar with Ant, apologies if I didn't search properly enough or by build is flawed, but I think this issue is simple.

While Building the Installer for our Netbeans Platform Product, we include a copy of the Java JDK (AdoptOpenJDK 11.0.5).

During the build, netbeans moves all files into a tmpdir, which works, but then moves them back again (this is because it eliminates the sub folder that way: blah/jdk to blah/tmp -> delete jdk -> blah/tmp to blah/).

Anyway, the problem is that this JDK contains a folder man/ with subfolders like ja_JP.UTF-8 and additional symlinks like jp to said directory.


Now the following is thrown:
UNEXPECTED ERROR - The file /build/installer/nbi_all/ext/infra/build/products/jdk/build/temp/jdk/man/ja should not exist!
        at org.apache.tools.ant.taskdefs.Move.deleteDir(Move.java:312)

Looking at the code: https://github.com/apache/ant/blob/master/src/main/org/apache/tools/ant/taskdefs/Move.java#L303 -> ja is not seen as a directory symlink, as the target (ja_JP.UTF-8) is already deleted (by the move operation, presumably)

Now I didn't dig any deeper into why the symlink isn't deleted when ja is commanded to be deleted, but I've found some similar bugs which all show that symlinks might not be supported on the copy/move operations.

See also: #63956, 
#14320 (things have changed, we have LinkOption.NOFOLLOW_LINKS, Files.isSymbolicLink(Path) and Path.toRealPath() now)

Also note that I don't know why the build.xml doesn't try to fully move the folder which would be faster (less IO) and better, but it could be because you can specify multiple source directories and they then get merged together.

Thanks in Advance!