Skip to content

Commit

Permalink
Test the Gradle Plugin against 7.0-milestone-1
Browse files Browse the repository at this point in the history
Closes gh-25103
  • Loading branch information
wilkinsona committed Feb 4, 2021
1 parent 0e326d6 commit d302510
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -48,4 +48,6 @@
*/
boolean configurationCache() default false;

String versionsLessThan() default "";

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

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
Expand All @@ -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<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(ExtensionContext context) {
return GRADLE_VERSIONS.stream().flatMap((version) -> {
Stream<String> 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<TestTemplateInvocationContext> 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));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -28,7 +28,7 @@
*
* @author Andy Wilkinson
*/
@GradleCompatibility
@GradleCompatibility(versionsLessThan = "7.0-milestone-1")
class MavenPluginActionIntegrationTests {

GradleBuild gradleBuild;
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -34,7 +34,7 @@
*
* @author Andy Wilkinson
*/
@GradleCompatibility
@GradleCompatibility(versionsLessThan = "7.0-milestone-1")
class MavenIntegrationTests {

GradleBuild gradleBuild;
Expand Down

0 comments on commit d302510

Please sign in to comment.