Merge branch '3.2.x'

Closes gh-40796
This commit is contained in:
Andy Wilkinson 2024-05-16 18:21:02 +01:00
commit 85acdf5165
2 changed files with 11 additions and 5 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,6 +19,8 @@ package org.springframework.boot.gradle.junit;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.TreeSet;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.gradle.util.GradleVersion; import org.gradle.util.GradleVersion;
@ -47,10 +49,14 @@ final class GradleCompatibilityExtension implements TestTemplateInvocationContex
@Override @Override
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(ExtensionContext context) { public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(ExtensionContext context) {
Stream<String> gradleVersions = GRADLE_VERSIONS.stream(); GradleVersion highestVersion = GRADLE_VERSIONS.stream()
.map(GradleVersion::version)
.collect(Collectors.toCollection(TreeSet::new))
.last();
GradleCompatibility gradleCompatibility = AnnotationUtils GradleCompatibility gradleCompatibility = AnnotationUtils
.findAnnotation(context.getRequiredTestClass(), GradleCompatibility.class) .findAnnotation(context.getRequiredTestClass(), GradleCompatibility.class)
.get(); .get();
Stream<String> gradleVersions = GRADLE_VERSIONS.stream();
if (StringUtils.hasText(gradleCompatibility.versionsLessThan())) { if (StringUtils.hasText(gradleCompatibility.versionsLessThan())) {
GradleVersion upperExclusive = GradleVersion.version(gradleCompatibility.versionsLessThan()); GradleVersion upperExclusive = GradleVersion.version(gradleCompatibility.versionsLessThan());
gradleVersions = gradleVersions gradleVersions = gradleVersions
@ -60,7 +66,7 @@ final class GradleCompatibilityExtension implements TestTemplateInvocationContex
List<TestTemplateInvocationContext> invocationContexts = new ArrayList<>(); List<TestTemplateInvocationContext> invocationContexts = new ArrayList<>();
invocationContexts.add(new GradleVersionTestTemplateInvocationContext(version, false)); invocationContexts.add(new GradleVersionTestTemplateInvocationContext(version, false));
boolean configurationCache = gradleCompatibility.configurationCache(); boolean configurationCache = gradleCompatibility.configurationCache();
if (configurationCache) { if (configurationCache && GradleVersion.version(version).equals(highestVersion)) {
invocationContexts.add(new GradleVersionTestTemplateInvocationContext(version, true)); invocationContexts.add(new GradleVersionTestTemplateInvocationContext(version, true));
} }
return invocationContexts.stream(); return invocationContexts.stream();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Andy Wilkinson * @author Andy Wilkinson
* @author Scott Frederick * @author Scott Frederick
*/ */
@GradleCompatibility(configurationCache = false) @GradleCompatibility
class NativeImagePluginActionIntegrationTests { class NativeImagePluginActionIntegrationTests {
GradleBuild gradleBuild; GradleBuild gradleBuild;