GH-31 - Fix build resource file detection for test execution optimizations.

This commit is contained in:
Oliver Drotbohm
2024-09-16 17:18:34 +02:00
parent a391e86ee8
commit 3773c0d175
3 changed files with 15 additions and 3 deletions

View File

@@ -255,7 +255,13 @@ public class Changes implements Iterable<Change> {
record OtherFileChange(String path) implements Change {
private static final Collection<String> CLASSPATH_RESOURCES = Set.of("src/main/resources", "src/test/resources");
private static final Collection<String> BUILD_FILES = Set.of("build.gradle", "build.kt", "pom.xml");
private static final Collection<String> BUILD_FILES = Set.of(
// Gradle
"build.gradle", "build.gradle.kts", "gradle.properties", "settings.gradle", "settings.gradle.kts",
// Maven
"pom.xml");
/**
* Returns whether the change affects a build resource.

View File

@@ -49,7 +49,13 @@ class ChangesUnitTests {
@TestFactory // GH-31
Stream<DynamicTest> detectsNonClasspathFileChange() {
var files = Stream.of("pom.xml", "build.gradle", "build.kt");
var files = Stream.of(
// Maven
"pom.xml",
// Gradle
"build.gradle", "build.gradle.kts", "gradle.properties", "settings.gradle", "settings.gradle.kts");
return DynamicTest.stream(files, it -> it + " is considered build resource", it -> {

View File

@@ -395,7 +395,7 @@ Tests will be selected for execution if they reside in either a root module, a m
The optimization will back off optimizing the execution under the following circumstances:
* The test execution originates from an IDE as we assume the execution is triggered explicitly.
* The set of changes contains a change to a resource related to a build system (`pom.xml`, `build.gradle`, `gradle.properties`).
* The set of changes contains a change to a resource related to a build system (`pom.xml`, `build.gradle(.kts)`, `gradle.properties`, and `settings.gradle(.kts)`).
* The set of changes contains a change to any classpath resource.
* The project does not contain a change at all (typical in a CI build).