File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed
plugin-gradle/src/main/java/com/diffplug/gradle/spotless Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -104,6 +104,23 @@ public void removeFormat(String name) {
104
104
}
105
105
}
106
106
107
+ boolean enforceCheck = true ;
108
+
109
+ /** Returns `true` if Gradle's `check` task should run `spotlessCheck`; `false` otherwise. */
110
+ public boolean isEnforceCheck () {
111
+ return enforceCheck ;
112
+ }
113
+
114
+ /**
115
+ * Configures Gradle's `check` task to run `spotlessCheck` if `true`,
116
+ * but to not do so if `false`.
117
+ *
118
+ * `true` by default.
119
+ */
120
+ public void setEnforceCheck (boolean enforceCheck ) {
121
+ this .enforceCheck = enforceCheck ;
122
+ }
123
+
107
124
private <T extends FormatExtension > void configure (String name , Class <T > clazz , Action <T > configure ) {
108
125
T value = maybeCreate (name , clazz );
109
126
configure .execute (value );
Original file line number Diff line number Diff line change @@ -103,9 +103,11 @@ public Object doCall(TaskExecutionGraph graph) {
103
103
// Add our check task as a dependency on the global check task
104
104
// getTasks() returns a "live" collection, so this works even if the
105
105
// 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
+ }
109
111
110
112
// clear spotless' cache when the user does a clean
111
113
project .getTasks ()
You can’t perform that action at this time.
0 commit comments