Skip to content

Commit f828147

Browse files
committed
Expand test coverage for the configuration cache, and better error message for failures.
1 parent d322c63 commit f828147

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

plugin-gradle/src/main/java/com/diffplug/gradle/spotless/SpotlessTaskImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ public void performAction(InputChanges inputs) throws Exception {
8383
}
8484
}
8585
} else {
86-
throw new GradleException("Spotless doesn't support configuration cache yet");
86+
throw new GradleException("Spotless doesn't support configuration cache yet.\n" +
87+
"Rerun with --no-configuration-cache");
8788
}
8889
}
8990

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/ConfigurationCacheTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
*/
1616
package com.diffplug.gradle.spotless;
1717

18+
import java.io.File;
1819
import java.io.IOException;
20+
import java.nio.file.Files;
21+
import java.nio.file.Path;
22+
import java.util.Comparator;
1923

2024
import org.gradle.testkit.runner.BuildResult;
2125
import org.gradle.testkit.runner.GradleRunner;
@@ -84,5 +88,19 @@ public void gjf() throws IOException {
8488
// but the second fails
8589
BuildResult failure = gradleRunner().withArguments("spotlessApply").buildAndFail();
8690
failure.getOutput().contains("> Spotless doesn't support configuration cache yet");
91+
92+
// and it will keep failing forever
93+
gradleRunner().withArguments("spotlessApply").buildAndFail();
94+
95+
// until you delete the .gradlle/configuration-cache folder
96+
File configCache = new File(super.rootFolder(), ".gradle/configuration-cache");
97+
Files.walk(configCache.toPath())
98+
.sorted(Comparator.reverseOrder())
99+
.map(Path::toFile)
100+
.forEach(File::delete);
101+
102+
// then it will work again (but only once)
103+
gradleRunner().withArguments("spotlessApply").build();
104+
gradleRunner().withArguments("spotlessApply").buildAndFail();
87105
}
88106
}

0 commit comments

Comments
 (0)