diff --git a/src/it/dangling-symlinks/setup.bsh b/src/it/dangling-symlinks/setup.bsh
index 4dc5667..e55b6ae 100644
--- a/src/it/dangling-symlinks/setup.bsh
+++ b/src/it/dangling-symlinks/setup.bsh
@@ -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.*;
@@ -25,18 +26,19 @@ 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 )
{
diff --git a/src/it/symlink-dont-follow/setup.bsh b/src/it/symlink-dont-follow/setup.bsh
index 50bec7f..b6b56cd 100644
--- a/src/it/symlink-dont-follow/setup.bsh
+++ b/src/it/symlink-dont-follow/setup.bsh
@@ -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.*;
@@ -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;
diff --git a/src/test/java/org/apache/maven/plugins/clean/Utils.java b/src/test/java/org/apache/maven/plugins/clean/Utils.java
deleted file mode 100644
index f96226d..0000000
--- a/src/test/java/org/apache/maven/plugins/clean/Utils.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.maven.plugins.clean;
-
-import java.io.File;
-
-import org.codehaus.plexus.util.cli.CommandLineUtils;
-import org.codehaus.plexus.util.cli.Commandline;
-
-/**
- * Testing helpers for the IT scripts.
- *
- * @author Benjamin Bentmann
- */
-public class Utils {
-
- /**
- * Creates a symbolic link.
- *
- * @param target The target (file or directory) of the link, must not be null
.
- * @param link The path to the link, must not be null
.
- * @return true
if the symlink could be created, false
otherwise.
- */
- public static boolean createSymlink(File target, File link) {
- try {
- Commandline cli = new Commandline();
- cli.setExecutable("ln");
- cli.createArg().setValue("-s");
- cli.createArg().setFile(target);
- cli.createArg().setFile(link);
- int code = CommandLineUtils.executeCommandLine(cli, System.out::println, System.err::println);
- return 0 == code;
- } catch (Exception e) {
- return false;
- }
- }
-}