|
19 | 19 | * under the License.
|
20 | 20 | */
|
21 | 21 |
|
| 22 | +import static org.junit.Assume.assumeTrue; |
| 23 | + |
22 | 24 | import java.io.File;
|
23 | 25 | import java.io.IOException;
|
24 | 26 | import java.nio.file.Files;
|
| 27 | +import java.nio.file.FileSystemException; |
25 | 28 | import java.nio.file.Path;
|
26 | 29 | import java.util.ArrayList;
|
27 | 30 | import java.util.Collection;
|
@@ -155,6 +158,27 @@ public void assertFileExists( ArtifactItem item, boolean exist )
|
155 | 158 | assertEquals( exist, file.exists() );
|
156 | 159 | }
|
157 | 160 |
|
| 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 | + |
158 | 182 | public void assertFilesAreLinks( Collection<ArtifactItem> items, boolean areLinks )
|
159 | 183 | {
|
160 | 184 | for ( ArtifactItem item : items )
|
@@ -268,6 +292,8 @@ public void testCopyToLocation()
|
268 | 292 | public void testLink()
|
269 | 293 | throws Exception
|
270 | 294 | {
|
| 295 | + assumeTrue("supports symbolic links", supportsSymbolicLinks); |
| 296 | + |
271 | 297 | List<ArtifactItem> list = stubFactory.getArtifactItems( stubFactory.getClassifiedArtifacts() );
|
272 | 298 |
|
273 | 299 | mojo.setArtifactItems( createArtifactItemArtifacts( list ) );
|
|
0 commit comments