Skip to content

Commit d302510

Browse files
committed
Test the Gradle Plugin against 7.0-milestone-1
Closes gh-25103
1 parent 0e326d6 commit d302510

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 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.
@@ -48,4 +48,6 @@
4848
*/
4949
boolean configurationCache() default false;
5050

51+
String versionsLessThan() default "";
52+
5153
}

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

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
import org.springframework.boot.gradle.testkit.GradleBuild;
3434
import org.springframework.boot.gradle.testkit.GradleBuildExtension;
35+
import org.springframework.util.StringUtils;
3536

3637
/**
3738
* {@link Extension} that runs {@link TestTemplate templated tests} against multiple
@@ -48,24 +49,33 @@ final class GradleCompatibilityExtension implements TestTemplateInvocationContex
4849
JavaVersion javaVersion = JavaVersion.current();
4950
if (javaVersion.isCompatibleWith(JavaVersion.VERSION_14)
5051
|| javaVersion.isCompatibleWith(JavaVersion.VERSION_13)) {
51-
GRADLE_VERSIONS = Arrays.asList("6.3", "6.4.1", "6.5.1", "6.6.1", "6.7.1", "current");
52+
GRADLE_VERSIONS = Arrays.asList("6.3", "6.4.1", "6.5.1", "6.6.1", "6.7.1", "current", "7.0-milestone-1");
5253
}
5354
else {
54-
GRADLE_VERSIONS = Arrays.asList("5.6.4", "6.3", "6.4.1", "6.5.1", "6.6.1", "6.7.1", "current");
55+
GRADLE_VERSIONS = Arrays.asList("5.6.4", "6.3", "6.4.1", "6.5.1", "6.6.1", "6.7.1", "current",
56+
"7.0-milestone-1");
5557
}
5658
}
5759

5860
@Override
5961
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(ExtensionContext context) {
60-
return GRADLE_VERSIONS.stream().flatMap((version) -> {
62+
Stream<String> gradleVersions = GRADLE_VERSIONS.stream().map((version) -> {
6163
if (version.equals("current")) {
62-
version = GradleVersion.current().getVersion();
64+
return GradleVersion.current().getVersion();
6365
}
66+
return version;
67+
});
68+
GradleCompatibility gradleCompatibility = AnnotationUtils
69+
.findAnnotation(context.getRequiredTestClass(), GradleCompatibility.class).get();
70+
if (StringUtils.hasText(gradleCompatibility.versionsLessThan())) {
71+
GradleVersion upperExclusive = GradleVersion.version(gradleCompatibility.versionsLessThan());
72+
gradleVersions = gradleVersions
73+
.filter((version) -> GradleVersion.version(version).compareTo(upperExclusive) < 0);
74+
}
75+
return gradleVersions.flatMap((version) -> {
6476
List<TestTemplateInvocationContext> invocationContexts = new ArrayList<>();
6577
invocationContexts.add(new GradleVersionTestTemplateInvocationContext(version, false));
66-
boolean configurationCache = AnnotationUtils
67-
.findAnnotation(context.getRequiredTestClass(), GradleCompatibility.class).get()
68-
.configurationCache();
78+
boolean configurationCache = gradleCompatibility.configurationCache();
6979
if (configurationCache && GradleVersion.version(version).compareTo(GradleVersion.version("6.7")) >= 0) {
7080
invocationContexts.add(new GradleVersionTestTemplateInvocationContext(version, true));
7181
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 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.
@@ -28,7 +28,7 @@
2828
*
2929
* @author Andy Wilkinson
3030
*/
31-
@GradleCompatibility
31+
@GradleCompatibility(versionsLessThan = "7.0-milestone-1")
3232
class MavenPluginActionIntegrationTests {
3333

3434
GradleBuild gradleBuild;

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/MavenIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 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.
@@ -34,7 +34,7 @@
3434
*
3535
* @author Andy Wilkinson
3636
*/
37-
@GradleCompatibility
37+
@GradleCompatibility(versionsLessThan = "7.0-milestone-1")
3838
class MavenIntegrationTests {
3939

4040
GradleBuild gradleBuild;

0 commit comments

Comments
 (0)