Skip to content

Commit 3cd78e8

Browse files
committed
Test custom steps with and without configuration cache.
1 parent 1ae0037 commit 3cd78e8

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

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

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2024 DiffPlug
2+
* Copyright 2016-2025 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,9 +17,39 @@
1717

1818
import java.io.IOException;
1919

20+
import org.gradle.testkit.runner.GradleRunner;
2021
import org.junit.jupiter.api.Test;
2122

22-
class BumpThisNumberIfACustomStepChangesTest extends GradleIntegrationHarness {
23+
abstract class BumpThisNumberIfACustomStepChangesTest extends GradleIntegrationHarness {
24+
private boolean useConfigCache;
25+
26+
BumpThisNumberIfACustomStepChangesTest(boolean useConfigCache) {
27+
this.useConfigCache = useConfigCache;
28+
}
29+
30+
static class WithConfigCache extends BumpThisNumberIfACustomStepChangesTest {
31+
WithConfigCache() {
32+
super(true);
33+
}
34+
}
35+
36+
static class WithoutConfigCache extends BumpThisNumberIfACustomStepChangesTest {
37+
WithoutConfigCache() {
38+
super(false);
39+
}
40+
}
41+
42+
@Override
43+
public GradleRunner gradleRunner() throws IOException {
44+
if (useConfigCache) {
45+
setFile("gradle.properties").toLines("org.gradle.unsafe.configuration-cache=true",
46+
"org.gradle.configuration-cache=true");
47+
return super.gradleRunner().withGradleVersion(GradleVersionSupport.CONFIGURATION_CACHE.version);
48+
} else {
49+
return super.gradleRunner();
50+
}
51+
}
52+
2353
private void writeBuildFile(String toInsert) throws IOException {
2454
setFile("build.gradle").toLines(
2555
"plugins {",

0 commit comments

Comments
 (0)