Skip to content

Commit a1d5369

Browse files
committed
Limit configuration cache testing to the latest version of Gradle
Closes gh-40794
1 parent f35ecfb commit a1d5369

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/junit/GradleCompatibilityExtension.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,6 +19,8 @@
1919
import java.util.ArrayList;
2020
import java.util.Arrays;
2121
import java.util.List;
22+
import java.util.TreeSet;
23+
import java.util.stream.Collectors;
2224
import java.util.stream.Stream;
2325

2426
import org.gradle.util.GradleVersion;
@@ -47,10 +49,14 @@ final class GradleCompatibilityExtension implements TestTemplateInvocationContex
4749

4850
@Override
4951
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(ExtensionContext context) {
50-
Stream<String> gradleVersions = GRADLE_VERSIONS.stream();
52+
GradleVersion highestVersion = GRADLE_VERSIONS.stream()
53+
.map(GradleVersion::version)
54+
.collect(Collectors.toCollection(TreeSet::new))
55+
.last();
5156
GradleCompatibility gradleCompatibility = AnnotationUtils
5257
.findAnnotation(context.getRequiredTestClass(), GradleCompatibility.class)
5358
.get();
59+
Stream<String> gradleVersions = GRADLE_VERSIONS.stream();
5460
if (StringUtils.hasText(gradleCompatibility.versionsLessThan())) {
5561
GradleVersion upperExclusive = GradleVersion.version(gradleCompatibility.versionsLessThan());
5662
gradleVersions = gradleVersions
@@ -60,7 +66,7 @@ public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContex
6066
List<TestTemplateInvocationContext> invocationContexts = new ArrayList<>();
6167
invocationContexts.add(new GradleVersionTestTemplateInvocationContext(version, false));
6268
boolean configurationCache = gradleCompatibility.configurationCache();
63-
if (configurationCache) {
69+
if (configurationCache && GradleVersion.version(version).equals(highestVersion)) {
6470
invocationContexts.add(new GradleVersionTestTemplateInvocationContext(version, true));
6571
}
6672
return invocationContexts.stream();

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/NativeImagePluginActionIntegrationTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -43,7 +43,7 @@
4343
* @author Andy Wilkinson
4444
* @author Scott Frederick
4545
*/
46-
@GradleCompatibility(configurationCache = false)
46+
@GradleCompatibility
4747
class NativeImagePluginActionIntegrationTests {
4848

4949
GradleBuild gradleBuild;

0 commit comments

Comments
 (0)