[MINVOKER-335] Preserve symlinks for copied files by slawekjaranowski · Pull Request #231 · apache/maven-invoker-plugin (original) (raw)

This IT is incomplete because the GHA Windows runners are configured not like a regular machine. It fails for me:

Running pre-build script: D:\Entwicklung\Projekte\maven-invoker-plugin\target\it\MINVOKER-335-symlinks-in-source\setup.groovy
java.nio.file.FileSystemException: D:\Entwicklung\Projekte\maven-invoker-plugin\target\it\MINVOKER-335-symlinks-in-source\src\it\clone-symlinks\testDirLink: Dem Client fehlt ein erforderliches Recht.

    at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:86)
    at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
    at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
    at sun.nio.fs.WindowsFileSystemProvider.createSymbolicLink(WindowsFileSystemProvider.java:585)
    at java.nio.file.Files.createSymbolicLink(Files.java:1043)
    at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)
    at Script1.run(Script1.groovy:31)
    at groovy.lang.GroovyShell.evaluate(GroovyShell.java:460)
    at groovy.lang.GroovyShell.evaluate(GroovyShell.java:495)
    at groovy.lang.GroovyShell.evaluate(GroovyShell.java:469)
    at org.apache.maven.shared.scriptinterpreter.GroovyScriptInterpreter.evaluateScript(GroovyScriptInterpreter.java:69)
    at org.apache.maven.shared.scriptinterpreter.ScriptRunner.executeRun(ScriptRunner.java:223)
    at org.apache.maven.shared.scriptinterpreter.ScriptRunner.run(ScriptRunner.java:160)
    at org.apache.maven.plugins.invoker.AbstractInvokerMojo.runBuild(AbstractInvokerMojo.java:1823)
    at org.apache.maven.plugins.invoker.AbstractInvokerMojo.runBuild(AbstractInvokerMojo.java:1545)
    at org.apache.maven.plugins.invoker.AbstractInvokerMojo.lambda$runBuilds$4(AbstractInvokerMojo.java:1307)
    at org.apache.maven.plugins.invoker.JobExecutor.lambda$forEach$0(JobExecutor.java:63)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:750)
Running post-build script: D:\Entwicklung\Projekte\maven-invoker-plugin\target\it\MINVOKER-335-symlinks-in-source\verify.groovy
java.nio.file.NoSuchFileException: D:\Entwicklung\Projekte\maven-invoker-plugin\target\it\MINVOKER-335-symlinks-in-source\target\it\clone-symlinks\testDirLink
    at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79)
    at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
    at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
    at sun.nio.fs.WindowsLinkSupport.readLink(WindowsLinkSupport.java:56)
    at sun.nio.fs.WindowsFileSystemProvider.readSymbolicLink(WindowsFileSystemProvider.java:628)
    at java.nio.file.Files.readSymbolicLink(Files.java:1432)
    at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)
    at Script1.run(Script1.groovy:25)
    at groovy.lang.GroovyShell.evaluate(GroovyShell.java:460)
    at groovy.lang.GroovyShell.evaluate(GroovyShell.java:495)
    at groovy.lang.GroovyShell.evaluate(GroovyShell.java:469)
    at org.apache.maven.shared.scriptinterpreter.GroovyScriptInterpreter.evaluateScript(GroovyScriptInterpreter.java:69)
    at org.apache.maven.shared.scriptinterpreter.ScriptRunner.executeRun(ScriptRunner.java:223)
    at org.apache.maven.shared.scriptinterpreter.ScriptRunner.run(ScriptRunner.java:160)
    at org.apache.maven.plugins.invoker.AbstractInvokerMojo.runPostBuildHook(AbstractInvokerMojo.java:1905)
    at org.apache.maven.plugins.invoker.AbstractInvokerMojo.runBuild(AbstractInvokerMojo.java:1886)
    at org.apache.maven.plugins.invoker.AbstractInvokerMojo.runBuild(AbstractInvokerMojo.java:1545)
    at org.apache.maven.plugins.invoker.AbstractInvokerMojo.lambda$runBuilds$4(AbstractInvokerMojo.java:1307)
    at org.apache.maven.plugins.invoker.JobExecutor.lambda$forEach$0(JobExecutor.java:63)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:750)

You cannot create a symlink on Windows unless you have an elevated shell or developer mode. See: https://www.reddit.com/r/Batch/comments/p8m0bn/creating_smbolic_link_symlink_without_admin/

You need to create a selector script which tries to create a symlink, if it succeeds you can continue with the IT otherwise you need to skipt it.