【问题标题】:Grails 3: gradle-clover-plugin integrationGrails 3:gradle-clover-plugin 集成
【发布时间】:2016-12-26 11:34:22
【问题描述】:

有没有人成功地将 gradle-clover-plugin 与 Grails 3 集成?我与 build.gradle 最接近的是:

clover {
    additionalSourceDirs = [new File("src/main/groovy"), new File("grails-app")] as Set
    additionalTestDirs = [new File("src/test/groovy/"), new File("src/integration-test/groovy")] as Set
    includes = ['/*.groovy', '/.java']
    testIncludes = ['/Spec.java']
    report {
        html = true
        xml = true
    }
}

grails 测试应用程序:

[clover-clean] Clover Version 3.2.0, built on October 21 2013 (build-908)
[clover-clean] Loaded from: C:\Users\abc3\.gradle\caches\modules-2\files-2.1\com.cenqua.clover\clover\3.2.0\e09feecf14644d92003ab037c30e483cf86b3e82\clover-3.2.0.jar
[clover-clean] Clover: Commercial License registered to Abc Inc.
[clover-setup] Clover Version 3.2.0, built on October 21 2013 (build-908)
[clover-setup] Loaded from: C:\Users\abc3\.gradle\caches\modules-2\files-2.1\com.cenqua.clover\clover\3.2.0\e09feecf14644d92003ab037c30e483cf86b3e82\clover-3.2.0.jar
[clover-setup] Clover: Commercial License registered to Abc Inc.
[clover-setup] Clover is enabled with initstring 'C:\Users\abc3\MyApp\build/.clover/clover.db-test'
[javac] : warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] : warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[copy] Copied 2 empty directories to 2 empty directories under C:\Users\abc3\MyApp\build\classes\main
[copy] Copied 2 empty directories to 2 empty directories under C:\Users\abc3\MyApp\build\classes\test
[move] Moving 14 files to C:\Users\abc3\MyApp\build\classes
[move] Moved 3 empty directories to 1 empty directory under C:\Users\abc3\MyApp\build\classes
[move] Moving 4 files to C:\Users\abc3\MyApp\build\classes
[move] Moved 3 empty directories to 1 empty directory under C:\Users\abc3\MyApp\build\classes
:compileIntegrationTestJava UP-TO-DATE
:compileIntegrationTestGroovy UP-TO-DATE
:processIntegrationTestResources UP-TO-DATE
:integrationTestClasses UP-TO-DATE
:integrationTest UP-TO-DATE
:mergeTestReports UP-TO-DATE

Clover 似乎正在运行,但我没有收到任何报告。

在 C:\Users\abc3\MyApp\build/.clover 中没有创建任何内容;我没有 .clover 目录。

  • Grails 版本:3.1.10
  • Groovy 版本:2.4.7
  • JVM 版本:1.8.0_71

有什么想法吗?

谢谢

标记

【问题讨论】:

    标签: grails gradle clover


    【解决方案1】:

    我已将Gradle-Clover-Plugin 用于 Grails 3.2.4 应用程序(使用 Gradle 3.0 包装器)。它正在工作,我在build.gradle 文件中所做的只是:

    首先添加classpath依赖:

    buildscript {
        dependencies {
            classpath 'com.bmuschko:gradle-clover-plugin:2.1.0'
        }
    }
    

    然后应用插件:

    apply plugin: 'com.bmuschko.clover'
    

    然后添加三叶草依赖:

    dependencies {
        clover 'org.openclover:clover:4.2.0'
    }
    

    然后添加一些配置:

    clover {
        // Although Clover is now open source the plugin 
        // still expects to find the license file. 
        // Any file will work.
        licenseLocation = File.createTempFile('clover', '.license').absolutePath
    
        // This is neededed to see which tests targeted code
        // In this particular project I'm only using Spock
        // specifications
        testIncludes = ['**/*Spec.groovy']
    
        // I would like to have both html and xml report
        report {
          html = true
          xml = true
        }
    }
    

    最后执行:

    ./gradlew cloverGenerateReport
    

    【讨论】:

    【解决方案2】:

    我可以让它与 grails 3.3.2 和 gradle 4.4 一起工作,但这是一项乏味的任务。这就是我所做的:

    1. gradle.properties

      grailsVersion=3.3.2 gormVersion=6.1.8.RELEASE gradleWrapperVersion=4.4 org.gradle.jvmargs=-Xms256m -Xmx2048m

    2. build.gradle

      apply plugin: 'java'
      apply plugin: 'com.bmuschko.clover'
      
      dependencies {
          clover 'org.openclover:clover:4.2.0'
          ...
          compile 'org.codehaus.groovy:groovy-all:2.4.7'
          ...
      }
      
      sourceSets.main.output.classesDir = new File(buildDir, "classes/main")
      integrationTest.testClassesDirs = sourceSets.integrationTest.output.classesDirs
      
      clover {
          licenseLocation = File.createTempFile('clover', '.license').absolutePath             
      
          excludes = ['**/Application.groovy',     
                      '**/BootStrap.groovy',
                      '**/UrlMappings.groovy',
                      '**/*GrailsPlugin.groovy',
                      '**/*Mock.groovy',
          ]
      
          testIncludes = ['**/*Spec.groovy']
          report {
              html = true
              xml = true
          }
      }   
      

    希望对你有帮助。

    【讨论】:

      【解决方案3】:

      grails-clover-plugin 可与基于 Gant 的 Grails 1 和 2 一起使用。 Grails 3 基于 Gradle,所以插件不兼容。

      对于 Grails 3,我会尝试在 Gradle 构建脚本中编写 Clover-Gradle 集成,而不是尝试采用 grails-clover-plugin。

      请看一下本页最近发布的代码sn-p:

      https://confluence.atlassian.com/display/CLOVER/Gradle+Clover+Plugin

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-09-05
        • 1970-01-01
        • 2011-04-19
        • 1970-01-01
        • 2013-02-22
        • 2018-11-12
        • 1970-01-01
        • 2011-12-11
        相关资源
        最近更新 更多