Skip to content

[MCLEAN-93] Support junctions on NTFS#10

Merged
gnodet merged 2 commits into
apache:masterfrom
gnodet:mclean-93
Jun 14, 2023
Merged

[MCLEAN-93] Support junctions on NTFS#10
gnodet merged 2 commits into
apache:masterfrom
gnodet:mclean-93

Conversation

@gnodet

@gnodet gnodet commented Jan 10, 2022

Copy link
Copy Markdown
Contributor

Jira issue: MCLEAN-93

@gnodet

gnodet commented Jan 10, 2022

Copy link
Copy Markdown
Contributor Author

I'm investigating if I can setup a test on windows. I've been sidetracked by trying to switch the tests to junit 5 / plexus-testing, but it's missing the helper methods to setup/lookup mojos...
I'll provide one asap.

@michael-o michael-o left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When can this happen? I mean, can we create a junction in Java without using native code?

Comment thread src/main/java/org/apache/maven/plugins/clean/Cleaner.java Outdated
@gnodet

gnodet commented Jan 10, 2022

Copy link
Copy Markdown
Contributor Author

When can this happen? I mean, can we create a junction in Java without using native code?

I'm going to experiment with something like:

        Path testDir = Paths.get( "target/test-dir" ).toAbsolutePath();
        Files.createDirectories( testDir );
        Path orgDir = testDir.resolve( "org-dir" );
        Path jctDir = testDir.resolve( "jct-dir" );
        Files.createDirectories( orgDir );

        Process process = new ProcessBuilder()
                .directory( testDir.toFile() )
                .command( "mklink", "/J", jctDir.toString(), orgDir.toString() )
                .start();
        int result = process.waitFor();

The idea comes from https://www.geeksforgeeks.org/creating-junction-points/

@gnodet

gnodet commented Jan 11, 2022

Copy link
Copy Markdown
Contributor Author

When can this happen? I mean, can we create a junction in Java without using native code?

@michael-o The test is here: https://github.com/apache/maven-clean-plugin/pull/10/files#diff-f51e0a6f6bcc199bb061d2f1b751c0740ae8cd016a1e87b5349758c4ee96e7d1R297-R321

@jvoccia

jvoccia commented Aug 22, 2022

Copy link
Copy Markdown

When can this happen? I mean, can we create a junction in Java without using native code?

Not sure if you are asking about this regarding "tests" or regarding what "real world" use case this could occur in, but if asking in the second case:

NPM does this on Windows. So if you link a NPM component with a package.json like:

{
  ...
  "dependencies": {
    "someTestServer": "file:src/test/node_server/someTestServer"
  }
}

You will get a node_modules directory like:
node_modules/someTestServer <- Junction Point pointing to: src/test/node_server/someTestServer

If you configure mvn clean to delete node_modules (or a directory above node_modules) - it will walk the junction point and delete your src files.

@michael-o

Copy link
Copy Markdown
Member

Stupid Windows!

@gnodet gnodet merged commit 7350464 into apache:master Jun 14, 2023
@jira-importer

Copy link
Copy Markdown

Resolve #174

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants