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
pull/35903/head
Andy Wilkinson 1 year ago
parent 27b8ec8a3d
commit 7d07c0d09c

@ -190,9 +190,7 @@ class JavaConventions {
if (isPredictiveTestSelectionEnabled()) { if (isPredictiveTestSelectionEnabled()) {
PredictiveTestSelectionExtension predictiveTestSelection = test.getExtensions() PredictiveTestSelectionExtension predictiveTestSelection = test.getExtensions()
.getByType(PredictiveTestSelectionExtension.class); .getByType(PredictiveTestSelectionExtension.class);
predictiveTestSelection.getEnabled().set(true); predictiveTestSelection.getEnabled().convention(true);
predictiveTestSelection.mustRun((mustRun) -> mustRun.getIncludeClasses()
.add("org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation.*"));
} }
} }

@ -196,26 +196,10 @@ dependencies {
testRuntimeOnly("org.springframework.security:spring-security-saml2-service-provider") testRuntimeOnly("org.springframework.security:spring-security-saml2-service-provider")
} }
test {
outputs.dir("${buildDir}/generated-snippets")
}
task dependencyVersions(type: org.springframework.boot.build.constraints.ExtractVersionConstraints) { task dependencyVersions(type: org.springframework.boot.build.constraints.ExtractVersionConstraints) {
enforcedPlatform(":spring-boot-project:spring-boot-dependencies") enforcedPlatform(":spring-boot-project:spring-boot-dependencies")
} }
tasks.withType(org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask) {
dependsOn dependencyVersions
doFirst {
def versionConstraints = dependencyVersions.versionConstraints
def integrationVersion = versionConstraints["org.springframework.integration:spring-integration-core"]
def integrationDocs = String.format("https://docs.spring.io/spring-integration/docs/%s/reference/html/", integrationVersion)
attributes "spring-integration-docs": integrationDocs
}
dependsOn test
inputs.dir("${buildDir}/generated-snippets").withPathSensitivity(PathSensitivity.RELATIVE).withPropertyName("generatedSnippets")
}
asciidoctor { asciidoctor {
sources { sources {
include "index.adoc" include "index.adoc"
@ -243,3 +227,31 @@ task zip(type: Zip) {
artifacts { artifacts {
documentation zip documentation zip
} }
tasks.named("test") {
filter {
excludeTestsMatching("org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation.*")
}
}
def documentationTest = tasks.register("documentationTest", Test) {
filter {
includeTestsMatching("org.springframework.boot.actuate.autoconfigure.endpoint.web.documentation.*")
}
outputs.dir("${buildDir}/generated-snippets")
predictiveSelection {
enabled = false
}
}
tasks.withType(org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask) {
dependsOn dependencyVersions
doFirst {
def versionConstraints = dependencyVersions.versionConstraints
def integrationVersion = versionConstraints["org.springframework.integration:spring-integration-core"]
def integrationDocs = String.format("https://docs.spring.io/spring-integration/docs/%s/reference/html/", integrationVersion)
attributes "spring-integration-docs": integrationDocs
}
dependsOn documentationTest
inputs.dir("${buildDir}/generated-snippets").withPathSensitivity(PathSensitivity.RELATIVE).withPropertyName("generatedSnippets")
}

@ -23,4 +23,7 @@ test {
} }
} }
} }
predictiveSelection {
enabled = false
}
} }

Loading…
Cancel
Save