You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Miłosz S (Jira)" <ji...@apache.org> on 2021/02/26 16:22:00 UTC
[jira] [Commented] (MCLEAN-58) Maven Clean Plugin ignores
followSymLinks parameter on Windows
[ https://issues.apache.org/jira/browse/MCLEAN-58?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17291739#comment-17291739 ]
Miłosz S commented on MCLEAN-58:
--------------------------------
Please also note that on Windows there are symlinks AND "junctions":
[https://docs.microsoft.com/en-us/windows/win32/fileio/hard-links-and-junctions]
And {{java.nio.file.Files.isSymbolicLink()}} is not detecting junctions, same like {{org.apache.maven.shared.utils.io.FileUtils}} from {{maven-shared-utils}}. To detect them, you should check for file attributes of given {{Path}}:
{code:java}
Path p = Paths.get("C:\\some\\path")
BasicFileAttributes attrs = Files.readAttributes(p, BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS);
boolean isJunction = attrs.isDirectory() && attrs.isOther();
{code}
^Above solution suggested [here on JDK JIRA|https://bugs.openjdk.java.net/browse/JDK-8031083?focusedCommentId=13444574&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-13444574]
> Maven Clean Plugin ignores followSymLinks parameter on Windows
> --------------------------------------------------------------
>
> Key: MCLEAN-58
> URL: https://issues.apache.org/jira/browse/MCLEAN-58
> Project: Maven Clean Plugin
> Issue Type: Bug
> Affects Versions: 2.5
> Reporter: Sergei Makarov
> Assignee: Kristian Rosenvold
> Priority: Major
> Fix For: 2.6.1
>
> Attachments: MavenCleanPluginNoFollowSymlinkBug.zip
>
>
> Most of old java software use getCanonicalFile() to determine symlink. But it is lie for windows. Lets look to org.apache.maven.plugin.clean.Cleaner:
> 147 File canonical = followSymlinks ? file : file.getCanonicalFile();
> 148 if ( followSymlinks || file.equals( canonical ) )
> getCanonicalFile() returns same path and folow symlink. In attached MavenCleanPluginNoFollowSymlinkBug.zip you found TestCase.bat that shows bug (just read it to understand than run). Unfortunately I know only one way to fix this - move to NIO that has isSymbolicLink() since java 1.7.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)