diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/junit/GradleCompatibility.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/junit/GradleCompatibility.java index 73fe2698f0..9617f0d94d 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/junit/GradleCompatibility.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/junit/GradleCompatibility.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,4 +48,6 @@ public @interface GradleCompatibility { */ boolean configurationCache() default false; + String versionsLessThan() default ""; + } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/junit/GradleCompatibilityExtension.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/junit/GradleCompatibilityExtension.java index 52238d14ab..025b426905 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/junit/GradleCompatibilityExtension.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/junit/GradleCompatibilityExtension.java @@ -32,6 +32,7 @@ import org.junit.platform.commons.util.AnnotationUtils; import org.springframework.boot.gradle.testkit.GradleBuild; import org.springframework.boot.gradle.testkit.GradleBuildExtension; +import org.springframework.util.StringUtils; /** * {@link Extension} that runs {@link TestTemplate templated tests} against multiple @@ -48,24 +49,33 @@ final class GradleCompatibilityExtension implements TestTemplateInvocationContex JavaVersion javaVersion = JavaVersion.current(); if (javaVersion.isCompatibleWith(JavaVersion.VERSION_14) || javaVersion.isCompatibleWith(JavaVersion.VERSION_13)) { - GRADLE_VERSIONS = Arrays.asList("6.3", "6.4.1", "6.5.1", "6.6.1", "6.7.1", "current"); + GRADLE_VERSIONS = Arrays.asList("6.3", "6.4.1", "6.5.1", "6.6.1", "6.7.1", "current", "7.0-milestone-1"); } else { - GRADLE_VERSIONS = Arrays.asList("5.6.4", "6.3", "6.4.1", "6.5.1", "6.6.1", "6.7.1", "current"); + GRADLE_VERSIONS = Arrays.asList("5.6.4", "6.3", "6.4.1", "6.5.1", "6.6.1", "6.7.1", "current", + "7.0-milestone-1"); } } @Override public Stream provideTestTemplateInvocationContexts(ExtensionContext context) { - return GRADLE_VERSIONS.stream().flatMap((version) -> { + Stream gradleVersions = GRADLE_VERSIONS.stream().map((version) -> { if (version.equals("current")) { - version = GradleVersion.current().getVersion(); + return GradleVersion.current().getVersion(); } + return version; + }); + GradleCompatibility gradleCompatibility = AnnotationUtils + .findAnnotation(context.getRequiredTestClass(), GradleCompatibility.class).get(); + if (StringUtils.hasText(gradleCompatibility.versionsLessThan())) { + GradleVersion upperExclusive = GradleVersion.version(gradleCompatibility.versionsLessThan()); + gradleVersions = gradleVersions + .filter((version) -> GradleVersion.version(version).compareTo(upperExclusive) < 0); + } + return gradleVersions.flatMap((version) -> { List invocationContexts = new ArrayList<>(); invocationContexts.add(new GradleVersionTestTemplateInvocationContext(version, false)); - boolean configurationCache = AnnotationUtils - .findAnnotation(context.getRequiredTestClass(), GradleCompatibility.class).get() - .configurationCache(); + boolean configurationCache = gradleCompatibility.configurationCache(); if (configurationCache && GradleVersion.version(version).compareTo(GradleVersion.version("6.7")) >= 0) { invocationContexts.add(new GradleVersionTestTemplateInvocationContext(version, true)); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/MavenPluginActionIntegrationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/MavenPluginActionIntegrationTests.java index b6a55b8a91..1575799b5a 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/MavenPluginActionIntegrationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/MavenPluginActionIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Andy Wilkinson */ -@GradleCompatibility +@GradleCompatibility(versionsLessThan = "7.0-milestone-1") class MavenPluginActionIntegrationTests { GradleBuild gradleBuild; diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/MavenIntegrationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/MavenIntegrationTests.java index 46a9f07b49..7f5c9a0dcc 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/MavenIntegrationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/MavenIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Andy Wilkinson */ -@GradleCompatibility +@GradleCompatibility(versionsLessThan = "7.0-milestone-1") class MavenIntegrationTests { GradleBuild gradleBuild;