Skip to content

Commit

Permalink
Makes check enforcement configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
gdecaso committed Apr 1, 2017
1 parent 0b20cd0 commit c116941
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ public void removeFormat(String name) {
}
}

/** Allows configuring whether the check {@link SpotlessTask} should be enforced when performing builds or not. */
public boolean enforceCheck = true;

private <T extends FormatExtension> void configure(String name, Class<T> clazz, Action<T> configure) {
T value = maybeCreate(name, clazz);
configure.execute(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,17 @@
*/
package com.diffplug.gradle.spotless;

import java.util.Map;

import com.diffplug.common.base.Errors;
import com.diffplug.spotless.SpotlessCache;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import groovy.lang.Closure;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.execution.TaskExecutionGraph;
import org.gradle.api.plugins.JavaBasePlugin;

import com.diffplug.common.base.Errors;
import com.diffplug.spotless.SpotlessCache;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import groovy.lang.Closure;
import java.util.Map;

public class SpotlessPlugin implements Plugin<Project> {
Project project;
Expand Down Expand Up @@ -103,9 +101,11 @@ public Object doCall(TaskExecutionGraph graph) {
// Add our check task as a dependency on the global check task
// getTasks() returns a "live" collection, so this works even if the
// task doesn't exist at the time this call is made
project.getTasks()
.matching(task -> task.getName().equals(JavaBasePlugin.CHECK_TASK_NAME))
.all(task -> task.dependsOn(rootCheckTask));
if (spotlessExtension.enforceCheck) {
project.getTasks()
.matching(task -> task.getName().equals(JavaBasePlugin.CHECK_TASK_NAME))
.all(task -> task.dependsOn(rootCheckTask));
}

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

0 comments on commit c116941

Please sign in to comment.