diff --git a/src/it/dangling-symlinks/setup.bsh b/src/it/dangling-symlinks/setup.bsh index 4dc5667..c59cb1f 100644 --- a/src/it/dangling-symlinks/setup.bsh +++ b/src/it/dangling-symlinks/setup.bsh @@ -18,6 +18,7 @@ */ import java.io.*; +import java.nio.file.*; import java.util.*; import java.util.jar.*; import java.util.regex.*; @@ -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; } diff --git a/src/it/symlink-dont-follow/setup.bsh b/src/it/symlink-dont-follow/setup.bsh index 50bec7f..1ea6c12 100644 --- a/src/it/symlink-dont-follow/setup.bsh +++ b/src/it/symlink-dont-follow/setup.bsh @@ -18,6 +18,7 @@ */ import java.io.*; +import java.nio.file.*; import java.util.*; import java.util.jar.*; import java.util.regex.*; @@ -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; } } 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; - } - } -}