mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-09-18 09:22:47 +00:00
Try to workaround file locking on windows
This commit is contained in:
@@ -29,6 +29,7 @@ import org.mvndaemon.mvnd.assertj.TestClientOutput;
|
|||||||
import org.mvndaemon.mvnd.client.Client;
|
import org.mvndaemon.mvnd.client.Client;
|
||||||
import org.mvndaemon.mvnd.client.DaemonParameters;
|
import org.mvndaemon.mvnd.client.DaemonParameters;
|
||||||
import org.mvndaemon.mvnd.common.Message;
|
import org.mvndaemon.mvnd.common.Message;
|
||||||
|
import org.mvndaemon.mvnd.common.Os;
|
||||||
import org.mvndaemon.mvnd.junit.MvndNativeTest;
|
import org.mvndaemon.mvnd.junit.MvndNativeTest;
|
||||||
import org.mvndaemon.mvnd.junit.TestUtils;
|
import org.mvndaemon.mvnd.junit.TestUtils;
|
||||||
|
|
||||||
@@ -90,7 +91,7 @@ public class SingleModuleNativeIT {
|
|||||||
final TestClientOutput o1 = new TestClientOutput();
|
final TestClientOutput o1 = new TestClientOutput();
|
||||||
client.execute(o1, "clean", "install", "-e", "-B").assertSuccess();
|
client.execute(o1, "clean", "install", "-e", "-B").assertSuccess();
|
||||||
|
|
||||||
TestUtils.deleteDir(localMavenRepo);
|
TestUtils.deleteDir(localMavenRepo, Os.current() != Os.WINDOWS);
|
||||||
|
|
||||||
final TestClientOutput o2 = new TestClientOutput();
|
final TestClientOutput o2 = new TestClientOutput();
|
||||||
client.execute(o2, "clean", "install", "-e", "-B").assertSuccess();
|
client.execute(o2, "clean", "install", "-e", "-B").assertSuccess();
|
||||||
|
@@ -38,9 +38,13 @@ public class TestUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Path deleteDir(Path dir) {
|
public static Path deleteDir(Path dir) {
|
||||||
|
return deleteDir(dir, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Path deleteDir(Path dir, boolean failOnError) {
|
||||||
if (Files.exists(dir)) {
|
if (Files.exists(dir)) {
|
||||||
try (Stream<Path> files = Files.walk(dir)) {
|
try (Stream<Path> files = Files.walk(dir)) {
|
||||||
files.sorted(Comparator.reverseOrder()).forEach(TestUtils::deleteFile);
|
files.sorted(Comparator.reverseOrder()).forEach(f -> deleteFile(f, failOnError));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("Could not walk " + dir, e);
|
throw new RuntimeException("Could not walk " + dir, e);
|
||||||
}
|
}
|
||||||
@@ -48,11 +52,15 @@ public class TestUtils {
|
|||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void deleteFile(Path f) {
|
private static void deleteFile(Path f, boolean failOnError) {
|
||||||
try {
|
try {
|
||||||
Files.delete(f);
|
Files.delete(f);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("Could not delete " + f, e);
|
if (failOnError) {
|
||||||
|
throw new RuntimeException("Could not delete " + f, e);
|
||||||
|
} else {
|
||||||
|
System.err.println("Error deleting " + f + ": " + e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user