diff --git a/src/it/dangling-symlinks/setup.groovy b/src/it/dangling-symlinks/setup.groovy index 81623d1..be18cfd 100644 --- a/src/it/dangling-symlinks/setup.groovy +++ b/src/it/dangling-symlinks/setup.groovy @@ -17,28 +17,24 @@ * under the License. */ -import java.io.*; import java.nio.file.*; -import java.util.*; -import java.util.jar.*; -import java.util.regex.*; -import org.apache.maven.plugins.clean.*; +import java.nio.file.attribute.*; 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 ); - Files.createSymbolicLink( link.toPath(), target.toPath() ); - if ( !link.exists() ) + Files.createSymbolicLink( link, target, new FileAttribute[0] ); + if ( !Files.exists( link, new LinkOption[0] ) ) { System.out.println( "Platform does not support symlinks, skipping test." ); } System.out.println( "Deleting symlink target " + target ); - target.delete(); + Files.delete( target ); } catch( Exception ex ) { diff --git a/src/it/symlink-dont-follow/setup.groovy b/src/it/symlink-dont-follow/setup.groovy index 7ae9bc5..37fac7e 100644 --- a/src/it/symlink-dont-follow/setup.groovy +++ b/src/it/symlink-dont-follow/setup.groovy @@ -17,12 +17,8 @@ * under the License. */ -import java.io.*; import java.nio.file.*; -import java.util.*; -import java.util.jar.*; -import java.util.regex.*; -import org.apache.maven.plugins.clean.*; +import java.nio.file.attribute.*; def pairs = [ @@ -34,13 +30,11 @@ def pairs = for ( pair : pairs ) { - File target = new File( basedir, pair[0] ); - File link = new File( basedir, pair[1] ); - println "Creating symlink " + link + " -> " + target; - Path targetPath = target.toPath(); - Path linkPath = link.toPath(); - Files.createSymbolicLink( linkPath, targetPath ); - if ( !link.exists() ) + Path target = basedir.toPath().resolve( pair[0] ); + Path link = basedir.toPath().resolve( pair[1] ); + System.out.println( "Creating symlink " + link + " -> " + target ); + Files.createSymbolicLink( link, target, new FileAttribute[0] ); + if ( !Files.exists( link, new LinkOption[0] ) ) { println "Platform does not support symlinks, skipping test."; return; diff --git a/src/main/java/org/apache/maven/plugins/clean/CleanMojo.java b/src/main/java/org/apache/maven/plugins/clean/CleanMojo.java index 44ceb48..e3a2004 100644 --- a/src/main/java/org/apache/maven/plugins/clean/CleanMojo.java +++ b/src/main/java/org/apache/maven/plugins/clean/CleanMojo.java @@ -188,7 +188,7 @@ public class CleanMojo implements org.apache.maven.api.plugin.Mojo { * ${maven.multiModuleProjectDirectory}/target/.clean directory will be used. If the * ${build.directory} has been modified, you'll have to adjust this property explicitly. * In order for fast clean to work correctly, this directory and the various directories that will be deleted - * should usually reside on the same volume. The exact conditions are system dependant though, but if an atomic + * should usually reside on the same volume. The exact conditions are system-dependent though, but if an atomic * move is not supported, the standard deletion mechanism will be used. * * @since 3.2 @@ -201,8 +201,8 @@ public class CleanMojo implements org.apache.maven.api.plugin.Mojo { * Mode to use when using fast clean. Values are: background to start deletion immediately and * waiting for all files to be deleted when the session ends, at-end to indicate that the actual * deletion should be performed synchronously when the session ends, or defer to specify that - * the actual file deletion should be started in the background when the session ends (this should only be used - * when maven is embedded in a long running process). + * the actual file deletion should be started in the background when the session ends. This should only be used + * when maven is embedded in a long-running process. * * @since 3.2 * @see #fast