【问题标题】:How create a single CodeNarc report for a multiple-project Gradle build如何为多项目 Gradle 构建创建单个 CodeNarc 报告
【发布时间】:2014-09-13 21:32:26
【问题描述】:

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

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

【问题讨论】:

    标签: gradle codenarc


    【解决方案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,以便您可以看到使用它的项目。

    这有帮助吗?

    干杯 康

    【讨论】:

    • 看起来很酷,但不幸的是我收到了这个错误消息Could not find property 'allGroovy' on source set 'main'。会不会是 Gradle 版本的问题?我正在使用 Gradle 2.1
    • 我也在使用 2.1。您是否将 codenarc 插件应用于根项目和子项目?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-11-18
    • 2015-04-26
    • 2021-11-28
    • 1970-01-01
    • 2019-03-26
    • 1970-01-01
    • 2016-03-30
    相关资源
    最近更新 更多