I took the subprojects/docs/samples/codeCoverage project and inserted and underscore in the name variable, so that checkstyle will fail the build:
package org.gradle.sample;
import java.lang.String;
class Person {
private String _name;
public String getName() {
return _name;
}
public void setName(String name) {
this._name = name;
}
}
Then I tried a few ways to get checkstyle to ignore failures. Via the checkstyle extension block (http://gradle.org/docs/current/dsl/org.gradle.api.Project.html#org.gradle.api.Project:checkstyle)
checkstyle {
ignoreFailures = true
}
Yet the build still fails. Following another forum post, got me this:
tasks.withType(Checkstyle) {ignoreFailures = true }
And I could extrapolate to this:
checkstyleMain {
ignoreFailures true
}
Those work.
I did some investigating and the extension CheckstyleExtension (extends CodeQualityExtension) has the value at the time which the checkstyle Task (checkstyleMain) is running, but the checkstyle task doesn’t have it. It appears that CheckstylePlugin.configureTaskDefaults setups up the task before I can configure the extension, so it tries to use a closure to lazy evaluate. I have a suspicion that it’s eagerly executing: ignoreFailures = { extension.ignoreFailures } because ignoreFailures on the task is a boolean. Or I’m doing it wrong. I think this is a bug.