ignoreFailures in checkstyle extension block is not propagating to checkstyleMain

(Justin Ryan) #1

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. :frowning: 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.

(Justin Ryan) #2

I should add that configuring ignoreFailures via checkstyleMain as part of subprojects() doesn’t work either:

checkstyleMain {
        ignoreFailures = true

The only thing the works is task.withType(Checkstyle) {ignoreFailures = true}

(Justin Ryan) #3

Created GRADLE-2163: AsmBackedClassGenerator.addGetter is not adding convention backed method for get() for boolean properties

Created pull for fix: https://github.com/gradle/gradle/pull/71