From 7e29a3c70b36cc89db318c5005db374712447d85 Mon Sep 17 00:00:00 2001 From: Scott Frederick Date: Tue, 26 Sep 2023 18:19:25 -0500 Subject: [PATCH] Use latest available Gradle version for Paketo system tests This ensures that the tests will run with the latest Java versions. See gh-37507 --- .../boot/testsupport/gradle/testkit/GradleVersions.java | 5 +++++ .../boot/image/paketo/PaketoBuilderTests.java | 5 +++++ .../image/paketo/PaketoBuilderTests-bootDistZipJarApp.gradle | 2 +- .../paketo/PaketoBuilderTests-plainDistZipJarApp.gradle | 2 +- .../boot/image/paketo/PaketoBuilderTests-plainWarApp.gradle | 2 +- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-test-support/src/main/java/org/springframework/boot/testsupport/gradle/testkit/GradleVersions.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-test-support/src/main/java/org/springframework/boot/testsupport/gradle/testkit/GradleVersions.java index aa95f70469..0b0b9451a5 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-test-support/src/main/java/org/springframework/boot/testsupport/gradle/testkit/GradleVersions.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-test-support/src/main/java/org/springframework/boot/testsupport/gradle/testkit/GradleVersions.java @@ -44,6 +44,11 @@ public final class GradleVersions { return allCompatible().get(0); } + public static String maximumCompatible() { + List versions = allCompatible(); + return versions.get(versions.size() - 1); + } + private static boolean isJavaVersion(JavaVersion version) { return JavaVersion.current().isCompatibleWith(version); } diff --git a/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/java/org/springframework/boot/image/paketo/PaketoBuilderTests.java b/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/java/org/springframework/boot/image/paketo/PaketoBuilderTests.java index f5a87d041e..cba59ef46b 100644 --- a/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/java/org/springframework/boot/image/paketo/PaketoBuilderTests.java +++ b/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/java/org/springframework/boot/image/paketo/PaketoBuilderTests.java @@ -46,6 +46,7 @@ import org.springframework.boot.image.assertions.ImageAssertions; import org.springframework.boot.image.junit.GradleBuildInjectionExtension; import org.springframework.boot.testsupport.gradle.testkit.GradleBuild; import org.springframework.boot.testsupport.gradle.testkit.GradleBuildExtension; +import org.springframework.boot.testsupport.gradle.testkit.GradleVersions; import org.springframework.util.StringUtils; import static org.assertj.core.api.Assertions.assertThat; @@ -72,6 +73,7 @@ class PaketoBuilderTests { this.gradleBuild.scriptPropertyFrom(new File("../../gradle.properties"), "nativeBuildToolsVersion"); this.gradleBuild.expectDeprecationMessages("BPL_SPRING_CLOUD_BINDINGS_ENABLED.*true.*Deprecated"); this.gradleBuild.expectDeprecationMessages("BOM table is deprecated"); + this.gradleBuild.gradleVersion(GradleVersions.maximumCompatible()); } @Test @@ -298,6 +300,9 @@ class PaketoBuilderTests { @EnabledForJreRange(max = JRE.JAVA_17) void nativeApp() throws Exception { this.gradleBuild.expectDeprecationMessages("uses or overrides a deprecated API"); + // these deprecations are transitive from the Native Build Tools Gradle plugin + this.gradleBuild.expectDeprecationMessages("has been deprecated. This is scheduled to be removed in Gradle 9.0"); + this.gradleBuild.expectDeprecationMessages("upgrading_version_8.html#deprecated_access_to_convention"); writeMainClass(); String imageName = "paketo-integration/" + this.gradleBuild.getProjectDir().getName(); ImageReference imageReference = ImageReference.of(ImageName.of(imageName)); diff --git a/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/resources/org/springframework/boot/image/paketo/PaketoBuilderTests-bootDistZipJarApp.gradle b/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/resources/org/springframework/boot/image/paketo/PaketoBuilderTests-bootDistZipJarApp.gradle index 229a60ced2..3fa25b5ed2 100644 --- a/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/resources/org/springframework/boot/image/paketo/PaketoBuilderTests-bootDistZipJarApp.gradle +++ b/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/resources/org/springframework/boot/image/paketo/PaketoBuilderTests-bootDistZipJarApp.gradle @@ -39,5 +39,5 @@ application { bootBuildImage { builder = "paketobuildpacks/builder-jammy-base:latest" archiveFile = bootDistZip.archiveFile - environment = ['BP_JVM_VERSION': project.targetCompatibility.getMajorVersion()] + environment = ['BP_JVM_VERSION': java.targetCompatibility.getMajorVersion()] } \ No newline at end of file diff --git a/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/resources/org/springframework/boot/image/paketo/PaketoBuilderTests-plainDistZipJarApp.gradle b/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/resources/org/springframework/boot/image/paketo/PaketoBuilderTests-plainDistZipJarApp.gradle index 2aad5c4558..ffffef7d4d 100644 --- a/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/resources/org/springframework/boot/image/paketo/PaketoBuilderTests-plainDistZipJarApp.gradle +++ b/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/resources/org/springframework/boot/image/paketo/PaketoBuilderTests-plainDistZipJarApp.gradle @@ -39,5 +39,5 @@ application { bootBuildImage { builder = "paketobuildpacks/builder-jammy-base:latest" archiveFile = distZip.archiveFile - environment = ['BP_JVM_VERSION': project.targetCompatibility.getMajorVersion()] + environment = ['BP_JVM_VERSION': java.targetCompatibility.getMajorVersion()] } \ No newline at end of file diff --git a/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/resources/org/springframework/boot/image/paketo/PaketoBuilderTests-plainWarApp.gradle b/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/resources/org/springframework/boot/image/paketo/PaketoBuilderTests-plainWarApp.gradle index 05fd1981a4..ffa9a9a096 100644 --- a/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/resources/org/springframework/boot/image/paketo/PaketoBuilderTests-plainWarApp.gradle +++ b/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/resources/org/springframework/boot/image/paketo/PaketoBuilderTests-plainWarApp.gradle @@ -32,5 +32,5 @@ war { bootBuildImage { builder = "paketobuildpacks/builder-jammy-base:latest" archiveFile = war.archiveFile - environment = ['BP_JVM_VERSION': project.targetCompatibility.getMajorVersion(), 'BP_TOMCAT_VERSION': '10.*'] + environment = ['BP_JVM_VERSION': java.targetCompatibility.getMajorVersion(), 'BP_TOMCAT_VERSION': '10.*'] }