Skip to content

Commit

Permalink
Merge branch '2.7.x'
Browse files Browse the repository at this point in the history
Closes gh-33676
  • Loading branch information
wilkinsona committed Jan 3, 2023
2 parents ce91415 + 84c021b commit 3bcc7ec
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ dependencies {
implementation(platform("org.springframework:spring-framework-bom:5.3.15"))
implementation("com.diffplug.gradle:goomph:3.37.2")
implementation("com.fasterxml.jackson.core:jackson-databind:2.11.4")
implementation("com.gradle:gradle-enterprise-gradle-plugin:3.12.1")
implementation("com.tngtech.archunit:archunit:1.0.0")
implementation("commons-codec:commons-codec:1.13")
implementation("org.apache.maven:maven-embedder:3.6.2")
implementation("org.asciidoctor:asciidoctor-gradle-jvm:3.3.2")
implementation("org.gradle:test-retry-gradle-plugin:1.4.1")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable:${kotlinVersion}")
implementation("org.springframework:spring-core")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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 All @@ -24,6 +24,7 @@
import java.util.TreeMap;
import java.util.stream.Collectors;

import com.gradle.enterprise.gradleplugin.testretry.TestRetryExtension;
import io.spring.javaformat.gradle.SpringJavaFormatPlugin;
import io.spring.javaformat.gradle.tasks.CheckFormat;
import io.spring.javaformat.gradle.tasks.Format;
Expand All @@ -46,8 +47,6 @@
import org.gradle.api.tasks.javadoc.Javadoc;
import org.gradle.api.tasks.testing.Test;
import org.gradle.external.javadoc.CoreJavadocOptions;
import org.gradle.testretry.TestRetryPlugin;
import org.gradle.testretry.TestRetryTaskExtension;

import org.springframework.boot.build.architecture.ArchitecturePlugin;
import org.springframework.boot.build.classpath.CheckClasspathForProhibitedDependencies;
Expand Down Expand Up @@ -164,16 +163,12 @@ private void configureTestConventions(Project project) {
test.setMaxHeapSize("1024M");
project.getTasks().withType(Checkstyle.class, test::mustRunAfter);
project.getTasks().withType(CheckFormat.class, test::mustRunAfter);
TestRetryExtension testRetry = test.getExtensions().getByType(TestRetryExtension.class);
testRetry.getFailOnPassedAfterRetry().set(true);
testRetry.getMaxRetries().set(isCi() ? 3 : 0);
});
project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> project.getDependencies()
.add(JavaPlugin.TEST_RUNTIME_ONLY_CONFIGURATION_NAME, "org.junit.platform:junit-platform-launcher"));
project.getPlugins().apply(TestRetryPlugin.class);
project.getTasks().withType(Test.class,
(test) -> project.getPlugins().withType(TestRetryPlugin.class, (testRetryPlugin) -> {
TestRetryTaskExtension testRetry = test.getExtensions().getByType(TestRetryTaskExtension.class);
testRetry.getFailOnPassedAfterRetry().set(true);
testRetry.getMaxRetries().set(isCi() ? 3 : 0);
}));
}

private boolean isCi() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2023 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 @@ -54,6 +54,9 @@ void setup(@TempDir File projectDir) throws IOException {
this.buildFile = new File(this.projectDir, "build.gradle");
File settingsFile = new File(this.projectDir, "settings.gradle");
try (PrintWriter out = new PrintWriter(new FileWriter(settingsFile))) {
out.println("plugins {");
out.println(" id 'com.gradle.enterprise'");
out.println("}");
out.println("include ':spring-boot-project:spring-boot-parent'");
}
File springBootParent = new File(this.projectDir, "spring-boot-project/spring-boot-parent/build.gradle");
Expand Down Expand Up @@ -175,17 +178,15 @@ void testRetryIsConfiguredWithThreeRetriesOnCI() throws IOException {
out.println("description 'Test'");
out.println("task retryConfig {");
out.println(" doLast {");
out.println(" println \"Retry plugin applied: ${plugins.hasPlugin('org.gradle.test-retry')}\"");
out.println(" test.retry {");
out.println(" test.retry {");
out.println(" println \"maxRetries: ${maxRetries.get()}\"");
out.println(" println \"failOnPassedAfterRetry: ${failOnPassedAfterRetry.get()}\"");
out.println(" }");
out.println(" }");
out.println("}");
}
assertThat(runGradle(Collections.singletonMap("CI", "true"), "retryConfig", "--stacktrace").getOutput())
.contains("Retry plugin applied: true").contains("maxRetries: 3")
.contains("failOnPassedAfterRetry: true");
.contains("maxRetries: 3").contains("failOnPassedAfterRetry: true");
}

@Test
Expand All @@ -198,17 +199,15 @@ void testRetryIsConfiguredWithZeroRetriesLocally() throws IOException {
out.println("description 'Test'");
out.println("task retryConfig {");
out.println(" doLast {");
out.println(" println \"Retry plugin applied: ${plugins.hasPlugin('org.gradle.test-retry')}\"");
out.println(" test.retry {");
out.println(" test.retry {");
out.println(" println \"maxRetries: ${maxRetries.get()}\"");
out.println(" println \"failOnPassedAfterRetry: ${failOnPassedAfterRetry.get()}\"");
out.println(" }");
out.println(" }");
out.println("}");
}
assertThat(runGradle(Collections.singletonMap("CI", "local"), "retryConfig", "--stacktrace").getOutput())
.contains("Retry plugin applied: true").contains("maxRetries: 0")
.contains("failOnPassedAfterRetry: true");
.contains("maxRetries: 0").contains("failOnPassedAfterRetry: true");
}

private BuildResult runGradle(String... args) {
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pluginManagement {
}

plugins {
id "com.gradle.enterprise" version "3.11.2"
id "com.gradle.enterprise" version "3.12.1"
id "io.spring.ge.conventions" version "0.0.12"
}

Expand Down

0 comments on commit 3bcc7ec

Please sign in to comment.