Skip to content

Commit 60fc531

Browse files
committed
Fail assumption when symlinks not supported
1 parent 2006d95 commit 60fc531

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/test/java/org/apache/maven/plugins/dependency/fromConfiguration/TestCopyMojo.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@
1919
* under the License.
2020
*/
2121

22+
import static org.junit.Assume.assumeTrue;
23+
2224
import java.io.File;
2325
import java.io.IOException;
2426
import java.nio.file.Files;
27+
import java.nio.file.FileSystemException;
2528
import java.nio.file.Path;
2629
import java.util.ArrayList;
2730
import java.util.Collection;
@@ -155,6 +158,27 @@ public void assertFileExists( ArtifactItem item, boolean exist )
155158
assertEquals( exist, file.exists() );
156159
}
157160

161+
private static final boolean supportsSymbolicLinks = supportsSymbolicLinks();
162+
163+
private static boolean supportsSymbolicLinks( )
164+
{
165+
try {
166+
Path target = Files.createTempFile( null, null );
167+
Path link = Files.createTempFile( null, null );
168+
Files.delete( link );
169+
try {
170+
Files.createSymbolicLink( link, target );
171+
} catch ( FileSystemException e ) {
172+
return false;
173+
}
174+
Files.delete( link );
175+
Files.delete( target );
176+
return true;
177+
} catch ( IOException e ) {
178+
throw new RuntimeException( e );
179+
}
180+
}
181+
158182
public void assertFilesAreLinks( Collection<ArtifactItem> items, boolean areLinks )
159183
{
160184
for ( ArtifactItem item : items )
@@ -268,6 +292,8 @@ public void testCopyToLocation()
268292
public void testLink()
269293
throws Exception
270294
{
295+
assumeTrue("supports symbolic links", supportsSymbolicLinks);
296+
271297
List<ArtifactItem> list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() );
272298

273299
mojo.setArtifactItems( createArtifactItemArtifacts( list ) );

0 commit comments

Comments
 (0)