Skip to content

Commit fbf7c32

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

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
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,23 @@ 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+
Files.createSymbolicLink(target, link);
169+
Files.delete(link);
170+
Files.delete(target);
171+
return true;
172+
} catch ( Exception e ) {
173+
return false;
174+
}
175+
}
176+
158177
public void assertFilesAreLinks( Collection<ArtifactItem> items, boolean areLinks )
159178
{
160179
for ( ArtifactItem item : items )
@@ -268,6 +287,8 @@ public void testCopyToLocation()
268287
public void testLink()
269288
throws Exception
270289
{
290+
assumeTrue("supports symbolic links", supportsSymbolicLinks);
291+
271292
List<ArtifactItem> list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() );
272293

273294
mojo.setArtifactItems( createArtifactItemArtifacts( list ) );

0 commit comments

Comments
 (0)