-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Archiver follows symlinks on Windows 7 #47
Comments
…ymlinks are not followed on Windows 7+ systems anymore
Unfortunately it is not that simple. Traditionally java has not had the capability to create, modify or delete windows symlinks. I though this was still the case, at least it is not the case for Os.FAMILY_WINDOWS in general, maybe a certain subset of these. If you can make unit tests that demonstrate symlink capabiltity on your given Windows version we can open for that (or find other technical docs describing when/what the limitations of the windows symlink implementation are). The default behaviour for years on end has been to follow symlinks like normal directories, since conventional wisdom has been that symlinks act somewhat like directories, so the code you are looking at is not odd from that perspective. |
Hi, from my point of view, the behaviour of working with symlinks should be the same across all OS (osx/linux/windows). If you are not sure, just add option to the pom.xml. |
There's always room for surprises ! Please clone plexus-io and run on your local os (mvn clean install). I just added some "capability" tests that may reveal the level of windows support. I'll see if I can find some windows boxes of my own |
Hi, |
I could confirm that on Java 8 + Windows 10 all tests are passing. |
This seems like a pretty cool thing to fix. Historically our symlink support has been weak/nonexistant and some of our current approaches are not good enough. I'm preparing a small post fot the maven developers list where we can discuss how the different issues should be handled. Please join the discussion there. |
This is actually not true when you look at the code
When you have machine that supports symlinks (eg. linux for your current implementation), the symlinks are NOT followed. I do not know if this is intentional
but from what you said this could be bug as well. |
Yes :) That's because historic behaviour was changed about a year ago. On platforms that support symlinks we NEVER follow them, because we are able to represent them correctly on the roundtrip. So we never "follow" symlnks (resolve them) when symlinks are supported, simply because we handle the link properly. I am still uncertain if there is any decent use case for resolving/following symlinks on platforms that support it. I'm still also working on the writeup I promised yesterday :) |
Hi, any news? |
Locally applied:
and I get this
The test looks broken to me because the target directory and file do not exist:
|
I need to revert my previous statement. The offending piece of code Origin:
Target:
If you have symlinks followed, it will resolve them as if there are no symlinks. I am inclined to throw that away altogether and pass |
@michael-o I don't quite follow you. Why do you want to replace collection.setFollowingSymLinks( !isSymlinkSupported() ); with collection.setFollowingSymLinks( false ); |
Simple reason, people don't understand what this parameter is for. The purpose is for the PlexusIoCollection: it completely resolves links, thus omitted them from the archive. Since this is disabled on Unix-like and cannot be configured, I cannot see a reason keeping the boolean condition. |
Am I getting things right that with collection.setFollowingSymLinks( false ); the archiver will simply copy symlinks as they are (treating the symlink as a 'file'), and with collection.setFollowingSymLinks( true ); the archiver will traverse the symlink and copy all files within it (treating the symlink as a directory)? What I want to ultimately achieve is to make plexus skip traversing into symlinks on my Windows 7+ system. As I have stated in the issue on top, we have symlinks (created at build) to huge directory trees (made from another symlinks, resolved tree could be like 100 000+ files) that we do not want to be processed by plexus archiver. As of now the The only big issue I can see is that symlinks on Windows 7+ can be created only under admin privileges as @plamentotev mentioned above. Even if you add the right for creating symlinks to the standard user he still can not create them (Microsoft, why u do this??). |
Correct, |
Awesome. But I may be careful with
because as @krosenvold mentioned, not every Windows version supports symlinks. |
No one will likely use XP or Vista for serious development or deployment. I'd consider Windows 7 as minimum. |
OK guys, if I receive no objections on the next couple of days, I will go on and resolve this issue by settings |
My main concern is about the file path separator. If you set
I've tried to create a simple zip file. If you extract it on Linux the symlink won't work. It points to My other concern is that a lot of tools does not support symlinks on Windows. For example some archivers will just extract the sylink as regular file. In my example
Maybe we should discuss it on the Maven Dev list before making Plexus Archiver not following symlink by default on Windows. After all this would affect the Assembly plug-in and it's used to create distribution packages for various OSes including Windows. Imagine a project that creates a distribution package with symbolic links for Linux and uses the same files to create the Windows package. With the current implementation the Windows package will contains the duplicated files instead of symlinks(correct me if I'm wrong here). In many cases that could be a desired behavior because many (if not most) archivers on Windows will not process the package correctly otherwise. If we change the Plexus Archiver default behavior we may broke projects like this one. I'm not saying that such projects are common (or even that exist), I'm just saying that we should be careful. As a side note, looks like the symlinks support on Windows is improving. Microsoft is introducing some improvements with the Windows 10 Creators Update. They will allow non-admin user to create symlinks. |
btw @krosenvold mentioned that he is preparing a post for the Maven developers list. But I don't know if he has done so. If there is such discussion on the list it would be useful if somebody post a link to it. |
And also I want to remind that |
@plamentotev Please go ahead and raise it on the dev list. |
FYI: Here is the post on the Maven dev list. |
And what about making it configurable? With maven-resources-plugin cooperation I could imagine something like this in the pom.xml:
For distribution packages you could simply leave current configuration or explicitly set |
That's a good proposal. @petr-ujezdsky Can you check what needs to be changed? I guess several components have to change..maybe even some model :-( |
I might find some time for investigation in like 3 weeks from now. I am currently at vacation :-) |
@plamentotev No reaction to your thread. I guess no one objects this. If won't receive any objection, I will turn this off by the end of the week. |
We have many symlinks pointing to huge directories within our project. Because this archiver follows symlinks on Windows machines, the build stalls when eg. copying standard resources.
I have found the bug at
AbstractArchiver.java
:This should be changed to something like
The text was updated successfully, but these errors were encountered: