|
37 | 37 | import org.gradle.work.InputChanges;
|
38 | 38 |
|
39 | 39 | import com.diffplug.common.base.StringPrinter;
|
| 40 | +import com.diffplug.spotless.FileSignature; |
40 | 41 | import com.diffplug.spotless.Formatter;
|
41 | 42 | import com.diffplug.spotless.FormatterStep;
|
42 | 43 | import com.diffplug.spotless.LineEnding;
|
@@ -68,22 +69,18 @@ public void performAction(InputChanges inputs) throws Exception {
|
68 | 69 | Files.createDirectories(outputDirectory.toPath());
|
69 | 70 | }
|
70 | 71 |
|
71 |
| - if (lineEndingsPolicy != null) { |
72 |
| - try (Formatter formatter = buildFormatter()) { |
73 |
| - for (FileChange fileChange : inputs.getFileChanges(target)) { |
74 |
| - File input = fileChange.getFile(); |
75 |
| - if (fileChange.getChangeType() == ChangeType.REMOVED) { |
76 |
| - deletePreviousResult(input); |
77 |
| - } else { |
78 |
| - if (input.isFile()) { |
79 |
| - processInputFile(formatter, input); |
80 |
| - } |
| 72 | + assertHydrated(this); |
| 73 | + try (Formatter formatter = buildFormatter()) { |
| 74 | + for (FileChange fileChange : inputs.getFileChanges(target)) { |
| 75 | + File input = fileChange.getFile(); |
| 76 | + if (fileChange.getChangeType() == ChangeType.REMOVED) { |
| 77 | + deletePreviousResult(input); |
| 78 | + } else { |
| 79 | + if (input.isFile()) { |
| 80 | + processInputFile(formatter, input); |
81 | 81 | }
|
82 | 82 | }
|
83 | 83 | }
|
84 |
| - } else { |
85 |
| - throw new GradleException("Spotless doesn't support configuration cache yet.\n" + |
86 |
| - "Rerun with --no-configuration-cache"); |
87 | 84 | }
|
88 | 85 | }
|
89 | 86 |
|
@@ -139,6 +136,19 @@ static boolean isHydrated(SpotlessTask task) {
|
139 | 136 | return task.lineEndingsPolicy != null;
|
140 | 137 | }
|
141 | 138 |
|
| 139 | + static void assertHydrated(SpotlessTask task) { |
| 140 | + if (!isHydrated(task)) { |
| 141 | + throw new GradleException("Spotless doesn't support configuration cache yet.\n" + |
| 142 | + "Rerun with --no-configuration-cache"); |
| 143 | + } |
| 144 | + } |
| 145 | + |
| 146 | + static GradleException cacheIsStale() { |
| 147 | + return new GradleException("Spotless daemon-local cache is stale. Regenerate the cache with\n" + |
| 148 | + " " + (FileSignature.machineIsWin() ? "rmdir /q /s" : "rm -rf") + " .gradle/configuration-cache\n" + |
| 149 | + "For more information see #123"); |
| 150 | + } |
| 151 | + |
142 | 152 | static class LiveCache {
|
143 | 153 | LineEnding.Policy lineEndingsPolicy;
|
144 | 154 | List<FormatterStep> steps;
|
|
0 commit comments