【发布时间】:2014-09-13 21:32:26
【问题描述】:
我有一个 Gradle 多项目构建,其中每个子项目都创建自己的 CodeNarc 报告。
是否可以为我的构建中的所有项目创建单个 CodeNarc 分析报告,而不是为每个项目创建单独的报告?
【问题讨论】:
我有一个 Gradle 多项目构建,其中每个子项目都创建自己的 CodeNarc 报告。
是否可以为我的构建中的所有项目创建单个 CodeNarc 分析报告,而不是为每个项目创建单独的报告?
【问题讨论】:
您可以创建自己的 CodeNarc 任务并使用其所有子项目的源集对其进行配置,如下所示。
task supernarc(type: CodeNarc) {
def allGroovySourceDirs = subprojects.collect { Project p -> p.sourceSets.main.allGroovy.getSrcDirs() }.flatten()
allGroovySourceDirs.each {
source(it)
}
// BTW, if you know you have some violations and don't want the builds to fail because of too many violations, you can increase the threshold as follows
maxPriority1Violations = 5
maxPriority2Violations = 5
maxPriority3Violations = 5
}
我为您创建了这个sample on Github,以便您可以看到使用它的项目。
这有帮助吗?
干杯 康
【讨论】:
Could not find property 'allGroovy' on source set 'main'。会不会是 Gradle 版本的问题?我正在使用 Gradle 2.1