Skip to content

Commit

Permalink
MCLEAN-110 Replaced Utils.createSymlink with Java 7 Files.createSymbo…
Browse files Browse the repository at this point in the history
…licLink
  • Loading branch information
peterdemaeyer committed Nov 6, 2024
1 parent 9073634 commit 0ee82d1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 63 deletions.
14 changes: 8 additions & 6 deletions src/it/dangling-symlinks/setup.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,28 @@
* under the License.
*/

import java.io.*;
import java.nio.file.*;
import java.nio.file.attribute.*;
import java.util.*;
import java.util.jar.*;
import java.util.regex.*;
import org.apache.maven.plugins.clean.*;

try
{
File targetDir = new File( basedir, "target" );
File link = new File( targetDir, "link" );
File target = new File( targetDir, "link-target.txt" );
Path targetDir = basedir.toPath().resolve( "target" );
Path link = targetDir.resolve( "link" );
Path target = targetDir.resolve( "link-target.txt" );

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

System.out.println( "Deleting symlink target " + target );
target.delete();
Files.delete( target );
}
catch( Throwable t )
{
Expand Down
10 changes: 6 additions & 4 deletions src/it/symlink-dont-follow/setup.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
* under the License.
*/

import java.io.*;
import java.nio.file.*;
import java.nio.file.attribute.*;
import java.util.*;
import java.util.jar.*;
import java.util.regex.*;
Expand All @@ -33,10 +34,11 @@ String[][] pairs =

for ( String[] pair : pairs )
{
File target = new File( basedir, pair[0] );
File link = new File( basedir, pair[1] );
Path target = basedir.toPath().resolve( pair[0] );
Path link = basedir.toPath().resolve( pair[1] );
System.out.println( "Creating symlink " + link + " -> " + target );
if ( !Utils.createSymlink( target, link ) || !link.exists() )
Files.createSymbolicLink( link, target, new FileAttribute[0] );
if ( !Files.exists( link, new LinkOption[0] ) )
{
System.out.println( "FAILURE, platform does not support symlinks, skipping test." );
return;
Expand Down
53 changes: 0 additions & 53 deletions src/test/java/org/apache/maven/plugins/clean/Utils.java

This file was deleted.

0 comments on commit 0ee82d1

Please sign in to comment.