You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2021/04/08 20:16:40 UTC

[maven-dependency-plugin] 03/03: Fail assumption when symlinks not supported

This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch MDEP-437
in repository https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git

commit 1a1a1690974308a9af23356bacb01f5f61986c52
Author: Markus KARG <ma...@headcrashing.eu>
AuthorDate: Sun Aug 16 15:55:52 2020 +0200

    Fail assumption when symlinks not supported
---
 .../dependency/fromConfiguration/TestCopyMojo.java | 26 ++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java
index 769aeb6..6dd2884 100644
--- a/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java
+++ b/src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java
@@ -19,9 +19,12 @@ package org.apache.maven.plugins.dependency.fromConfiguration;
  * under the License.    
  */
 
+import static org.junit.Assume.assumeTrue;
+
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
+import java.nio.file.FileSystemException;
 import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -155,6 +158,27 @@ public class TestCopyMojo
         assertEquals( exist, file.exists() );
     }
 
+    private static final boolean supportsSymbolicLinks = supportsSymbolicLinks();
+
+    private static boolean supportsSymbolicLinks( )
+    {
+        try {
+            Path target = Files.createTempFile( null, null );
+            Path link = Files.createTempFile( null, null );
+            Files.delete( link );
+            try {
+                Files.createSymbolicLink( link, target );
+            } catch ( FileSystemException e ) {
+                return false;
+            }
+            Files.delete( link );
+            Files.delete( target );
+            return true;
+        } catch ( IOException e ) {
+            throw new RuntimeException( e );
+        }
+    }
+
     public void assertFilesAreLinks( Collection<ArtifactItem> items, boolean areLinks )
     {
         for ( ArtifactItem item : items )
@@ -268,6 +292,8 @@ public class TestCopyMojo
     public void testLink()
         throws Exception
     {
+        assumeTrue("supports symbolic links", supportsSymbolicLinks);
+
         List<ArtifactItem> list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() );
 
         mojo.setArtifactItems( createArtifactItemArtifacts( list ) );