Skip to content

Commit 4ce6427

Browse files
committed
Fail assumption when symlinks not supported
1 parent 2006d95 commit 4ce6427

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

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

+25
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
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;
@@ -155,6 +157,27 @@ public void assertFileExists( ArtifactItem item, boolean exist )
155157
assertEquals( exist, file.exists() );
156158
}
157159

160+
private static final boolean supportsSymbolicLinks = supportsSymbolicLinks();
161+
162+
private static boolean supportsSymbolicLinks( )
163+
{
164+
try {
165+
Path target = Files.createTempFile( null, null );
166+
Path link = Files.createTempFile( null, null );
167+
Files.delete( link );
168+
try {
169+
Files.createSymbolicLink( link, target );
170+
} catch ( IOException e ) {
171+
return false;
172+
}
173+
Files.delete( link );
174+
Files.delete( target );
175+
return true;
176+
} catch ( IOException e ) {
177+
throw new RuntimeException( e );
178+
}
179+
}
180+
158181
public void assertFilesAreLinks( Collection<ArtifactItem> items, boolean areLinks )
159182
{
160183
for ( ArtifactItem item : items )
@@ -268,6 +291,8 @@ public void testCopyToLocation()
268291
public void testLink()
269292
throws Exception
270293
{
294+
assumeTrue("supports symbolic links", supportsSymbolicLinks);
295+
271296
List<ArtifactItem> list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() );
272297

273298
mojo.setArtifactItems( createArtifactItemArtifacts( list ) );

0 commit comments

Comments
 (0)