Skip to content

Commit 0711a77

Browse files
committed
Makes check enforcement configurable
1 parent 0b20cd0 commit 0711a77

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ public void removeFormat(String name) {
104104
}
105105
}
106106

107+
/** Allows configuring whether the check {@link SpotlessTask} should be enforced when performing builds or not. */
108+
public boolean enforceCheck = true;
109+
107110
private <T extends FormatExtension> void configure(String name, Class<T> clazz, Action<T> configure) {
108111
T value = maybeCreate(name, clazz);
109112
configure.execute(value);

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,11 @@ public Object doCall(TaskExecutionGraph graph) {
103103
// Add our check task as a dependency on the global check task
104104
// getTasks() returns a "live" collection, so this works even if the
105105
// task doesn't exist at the time this call is made
106-
project.getTasks()
107-
.matching(task -> task.getName().equals(JavaBasePlugin.CHECK_TASK_NAME))
108-
.all(task -> task.dependsOn(rootCheckTask));
106+
if (spotlessExtension.enforceCheck) {
107+
project.getTasks()
108+
.matching(task -> task.getName().equals(JavaBasePlugin.CHECK_TASK_NAME))
109+
.all(task -> task.dependsOn(rootCheckTask));
110+
}
109111

110112
// clear spotless' cache when the user does a clean
111113
project.getTasks()

0 commit comments

Comments
 (0)