Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes dependency on Java check configurable #95

Merged
merged 1 commit into from
Apr 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,23 @@ public void removeFormat(String name) {
}
}

boolean enforceCheck = true;

/** Returns `true` if Gradle's `check` task should run `spotlessCheck`; `false` otherwise. */
public boolean isEnforceCheck() {
return enforceCheck;
}

/**
* Configures Gradle's `check` task to run `spotlessCheck` if `true`,
* but to not do so if `false`.
*
* `true` by default.
*/
public void setEnforceCheck(boolean enforceCheck) {
this.enforceCheck = enforceCheck;
}

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 @@ -103,9 +103,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