diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests.java index b20924ad7d6..9202d349b15 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests.java @@ -317,8 +317,17 @@ class BootBuildImageIntegrationTests { Path launchCachePath = Paths.get(tempDir, "junit-image-cache-" + projectName + "-launch"); assertThat(buildCachePath).exists().isDirectory(); assertThat(launchCachePath).exists().isDirectory(); - FileSystemUtils.deleteRecursively(buildCachePath); - FileSystemUtils.deleteRecursively(launchCachePath); + cleanupCache(buildCachePath); + cleanupCache(launchCachePath); + } + + private static void cleanupCache(Path buildCachePath) { + try { + FileSystemUtils.deleteRecursively(buildCachePath); + } + catch (Exception ex) { + // ignore + } } @TestTemplate diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/BuildImageTests.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/BuildImageTests.java index b4d0fffeb5b..ab33e71ed8f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/BuildImageTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/BuildImageTests.java @@ -419,11 +419,20 @@ class BuildImageTests extends AbstractArchiveIntegrationTests { Path launchCachePath = Paths.get(tempDir, "junit-image-cache-" + testBuildId + "-launch"); assertThat(buildCachePath).exists().isDirectory(); assertThat(launchCachePath).exists().isDirectory(); - FileSystemUtils.deleteRecursively(buildCachePath); - FileSystemUtils.deleteRecursively(launchCachePath); + cleanupCache(buildCachePath); + cleanupCache(launchCachePath); }); } + private static void cleanupCache(Path buildCachePath) { + try { + FileSystemUtils.deleteRecursively(buildCachePath); + } + catch (Exception ex) { + // ignore + } + } + @TestTemplate void whenBuildImageIsInvokedWithCreatedDate(MavenBuild mavenBuild) { String testBuildId = randomString();