如何为多项目Gradle构建创建单个CodeNarc报告

时间:2014-09-13 21:32:27

标签: gradle codenarc

我有一个Gradle多项目构建,每个子项目都会创建自己的CodeNarc报告。

是否有可能为我的构建中的所有项目创建单个CodeNarc分析报告,而不是为每个项目创建单独的报告?

1 个答案:

答案 0 :(得分:1)

您可以创建自己的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,以便您可以看到使用它的项目。

这有帮助吗?

干杯 KON