在Gradle 1.10中配置findBugs

在Gradle 1.10中配置findBugs,gradle,report,findbugs,Gradle,Report,Findbugs,我正在尝试在项目中使用配置findbugs findbugs { ignoreFailures = true reports { html { enabled = true } xml.enabled = !html.enabled } } 但出现了一个错误 Could not find method reports() for arguments [quality_4gppo4hjtn3ur86ac71a18pai6$_run_

我正在尝试在项目中使用配置findbugs

findbugs {
    ignoreFailures = true
    reports {
        html { enabled = true }
        xml.enabled = !html.enabled
    }
}
但出现了一个错误

  Could not find method reports() for arguments

 [quality_4gppo4hjtn3ur86ac71a18pai6$_run_closure2_closure4@6651ccf] 
on root project 'Project'.

这段代码曾在我以前的一个Gradle 1.7项目中使用过,并且正在运行。

您可以在FindBugs任务中使用reports方法。findbugs插件为每个源集创建一个。因此,如果您想在主类上使用FindBugs,您可以使用

findbugsMain {
    ignoreFailures = true
    reports {
        html { enabled = true }
        xml.enabled = !html.enabled
    }
}
如果您希望以相同的方式配置所有findbugs任务,则只需将相同的配置应用于所有findbugs任务:

tasks.withType(FindBugs) {
    ignoreFailures = true
    reports {
        html { enabled = true }
        xml.enabled = !html.enabled
    }
}

好的,但在我的例子中,我有20多个源集,我想一次配置所有源集。