簡體   English   中英

如何為多項目Gradle構建創建單個CodeNarc報告

[英]How create a single CodeNarc report for a multiple-project Gradle build

我有一個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

}

我為您在Github上創建了此示例,因此您可以看到一個使用它的項目。

有幫助嗎?

干杯

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM