Skip to content

Commit 7d07c0d

Browse files
committed
Polish configuration related to predictive test selection
Most notably, this commit splits the tests that use Spring REST Docs out into a separate task for which predictive test selection is disabled. This allows it to be cached and use Gradle's built-in up-to-date checking, thereby avoiding the generation of new snippets and the need to then run the asciidoctor and asciidoctorPdf tasks. It also updates spring-boot-smoke-test-junit-vintage to disable predictive test selection so that we can continue to assert that the some tests were executed. See gh-35869
1 parent 27b8ec8 commit 7d07c0d

File tree

3 files changed

+32
-19
lines changed
  • buildSrc/src/main/java/org/springframework/boot/build
  • spring-boot-project/spring-boot-actuator-autoconfigure
  • spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-junit-vintage

3 files changed

+32
-19
lines changed

buildSrc/src/main/java/org/springframework/boot/build/JavaConventions.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,7 @@ private void configurePredictiveTestSelection(Test test) {
190190
if (isPredictiveTestSelectionEnabled()) {
191191
PredictiveTestSelectionExtension predictiveTestSelection = test.getExtensions()
192192
.getByType(PredictiveTestSelectionExtension.class);
193-
predictiveTestSelection.getEnabled().set(true);
194-
predictiveTestSelection.mustRun((mustRun) -> mustRun.getIncludeClasses()
195-
.add("org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation.*"));
193+
predictiveTestSelection.getEnabled().convention(true);
196194
}
197195
}
198196

spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle

+28-16
Original file line numberDiff line numberDiff line change
@@ -196,26 +196,10 @@ dependencies {
196196
testRuntimeOnly("org.springframework.security:spring-security-saml2-service-provider")
197197
}
198198

199-
test {
200-
outputs.dir("${buildDir}/generated-snippets")
201-
}
202-
203199
task dependencyVersions(type: org.springframework.boot.build.constraints.ExtractVersionConstraints) {
204200
enforcedPlatform(":spring-boot-project:spring-boot-dependencies")
205201
}
206202

207-
tasks.withType(org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask) {
208-
dependsOn dependencyVersions
209-
doFirst {
210-
def versionConstraints = dependencyVersions.versionConstraints
211-
def integrationVersion = versionConstraints["org.springframework.integration:spring-integration-core"]
212-
def integrationDocs = String.format("https://docs.spring.io/spring-integration/docs/%s/reference/html/", integrationVersion)
213-
attributes "spring-integration-docs": integrationDocs
214-
}
215-
dependsOn test
216-
inputs.dir("${buildDir}/generated-snippets").withPathSensitivity(PathSensitivity.RELATIVE).withPropertyName("generatedSnippets")
217-
}
218-
219203
asciidoctor {
220204
sources {
221205
include "index.adoc"
@@ -243,3 +227,31 @@ task zip(type: Zip) {
243227
artifacts {
244228
documentation zip
245229
}
230+
231+
tasks.named("test") {
232+
filter {
233+
excludeTestsMatching("org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation.*")
234+
}
235+
}
236+
237+
def documentationTest = tasks.register("documentationTest", Test) {
238+
filter {
239+
includeTestsMatching("org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation.*")
240+
}
241+
outputs.dir("${buildDir}/generated-snippets")
242+
predictiveSelection {
243+
enabled = false
244+
}
245+
}
246+
247+
tasks.withType(org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask) {
248+
dependsOn dependencyVersions
249+
doFirst {
250+
def versionConstraints = dependencyVersions.versionConstraints
251+
def integrationVersion = versionConstraints["org.springframework.integration:spring-integration-core"]
252+
def integrationDocs = String.format("https://docs.spring.io/spring-integration/docs/%s/reference/html/", integrationVersion)
253+
attributes "spring-integration-docs": integrationDocs
254+
}
255+
dependsOn documentationTest
256+
inputs.dir("${buildDir}/generated-snippets").withPathSensitivity(PathSensitivity.RELATIVE).withPropertyName("generatedSnippets")
257+
}

spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-junit-vintage/build.gradle

+3
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ test {
2323
}
2424
}
2525
}
26+
predictiveSelection {
27+
enabled = false
28+
}
2629
}

0 commit comments

Comments
 (0)