From 89a86e91f5ccd0bba593f52fb2aac14ce7851ba9 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 20 Sep 2023 14:39:48 +0100 Subject: [PATCH] Avoid deprecation warning with Gradle 8.4-rc-1 Closes gh-37493 --- .../boot/gradle/tasks/buildinfo/BuildInfoProperties.java | 8 +++++++- .../boot/testsupport/gradle/testkit/GradleVersions.java | 8 ++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoProperties.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoProperties.java index 1f25a56c55..65ca63b43f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoProperties.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoProperties.java @@ -28,6 +28,7 @@ import org.gradle.api.provider.Property; import org.gradle.api.provider.Provider; import org.gradle.api.tasks.Input; import org.gradle.api.tasks.Optional; +import org.gradle.util.GradleVersion; /** * The properties that are written into the {@code build-info.properties} file. @@ -38,6 +39,8 @@ import org.gradle.api.tasks.Optional; @SuppressWarnings("serial") public class BuildInfoProperties implements Serializable { + private static final GradleVersion GRADLE_7_4 = GradleVersion.version("7.4"); + private transient Instant creationTime = Instant.now(); private final Property group; @@ -74,7 +77,10 @@ public class BuildInfoProperties implements Serializable { @SuppressWarnings("deprecation") private Provider forUseAtConfigurationTime(Provider provider) { - return provider.forUseAtConfigurationTime(); + if (GradleVersion.current().compareTo(GRADLE_7_4) < 0) { + return provider.forUseAtConfigurationTime(); + } + return provider; } /** 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 5df8846585..dd4b6f28e7 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 @@ -34,15 +34,15 @@ public final class GradleVersions { public static List allCompatible() { if (isJava18()) { - return Arrays.asList("7.3.3", GradleVersion.current().getVersion(), "8.0.2", "8.3"); + return Arrays.asList("7.3.3", GradleVersion.current().getVersion(), "8.0.2", "8.3", "8.4-rc-1"); } if (isJava17()) { - return Arrays.asList("7.2", GradleVersion.current().getVersion(), "8.0.2", "8.3"); + return Arrays.asList("7.2", GradleVersion.current().getVersion(), "8.0.2", "8.3", "8.4-rc-1"); } if (isJava16()) { - return Arrays.asList("7.0.2", GradleVersion.current().getVersion(), "8.0.2", "8.3"); + return Arrays.asList("7.0.2", GradleVersion.current().getVersion(), "8.0.2", "8.3", "8.4-rc-1"); } - return Arrays.asList("6.8.3", "6.9.4", "7.0.2", GradleVersion.current().getVersion(), "8.0.2", "8.3"); + return Arrays.asList("6.8.3", "6.9.4", "7.0.2", GradleVersion.current().getVersion(), "8.0.2", "8.3", "8.4-rc-1"); } public static String minimumCompatible() {