Skip to content

Commit

Permalink
Use Files.createSymbolicLink instead of shelling out
Browse files Browse the repository at this point in the history
  • Loading branch information
elharo committed Nov 14, 2024
1 parent 68d4eca commit e6723b0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 59 deletions.
10 changes: 6 additions & 4 deletions src/it/dangling-symlinks/setup.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import java.io.*;
import java.nio.file.*;
import java.util.*;
import java.util.jar.*;
import java.util.regex.*;
Expand All @@ -30,17 +31,18 @@ try
File target = new File( targetDir, "link-target.txt" );

System.out.println( "Creating symlink " + link + " -> " + target );
if ( !Utils.createSymlink( target, link ) || !link.exists() )
Files.createSymbolicLink( target, link );
if ( !link.exists() )
{
System.out.println( "FAILURE, platform does not support symlinks, skipping test." );
System.out.println( "Platform does not support symlinks, skipping test." );
}

System.out.println( "Deleting symlink target " + target );
target.delete();
}
catch( Throwable t )
catch( Exception ex )
{
t.printStackTrace();
ex.printStackTrace();
return false;
}

Expand Down
6 changes: 4 additions & 2 deletions src/it/symlink-dont-follow/setup.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import java.io.*;
import java.nio.file.*;
import java.util.*;
import java.util.jar.*;
import java.util.regex.*;
Expand All @@ -36,9 +37,10 @@ for ( String[] pair : pairs )
File target = new File( basedir, pair[0] );
File link = new File( basedir, pair[1] );
System.out.println( "Creating symlink " + link + " -> " + target );
if ( !Utils.createSymlink( target, link ) || !link.exists() )
Files.createSymbolicLink( target, link );
if ( !link.exists() )
{
System.out.println( "FAILURE, platform does not support symlinks, skipping test." );
System.out.println( "Platform does not support symlinks, skipping test." );
return;
}
}
53 changes: 0 additions & 53 deletions src/test/java/org/apache/maven/plugins/clean/Utils.java

This file was deleted.

0 comments on commit e6723b0

Please sign in to comment.