Gradle skipping jacoco coverage plugin

醉酒当歌 提交于 2021-01-24 07:31:10

问题


I know there are a lot of similar questions for this on stackexchange but this is driving me crazy and nothing from any other answers have helped me. I've used just about every force flag for gradle I can find.

My Gradle version is 2.2.1

My build.gradle

buildscript {
ext {
    springBootVersion = '1.5.3.RELEASE'
}
repositories {
    mavenCentral()
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    classpath("se.transmode.gradle:gradle-docker:1.2")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'application'
apply plugin: 'docker'
apply plugin: 'jacoco'

version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
  mavenCentral()
}


ext {
  springCloudVersion = 'Dalston.RELEASE'
}

test {
  include 'src/test/java'
  finalizedBy jacocoTestReport
}

jacocoTestReport {
   reports {
     xml.enabled true
     csv.enabled false
     html.enabled false
     xml.destination "${buildDir}/jacoco"
 }  
}
dependencyManagement {
  imports {
    mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
  }
}

When I run gradle test or gradle clean test jacocoTestReport or gradle clean --re-run etc etc I get the same results.

gradle test
:compileJava
:processResources
:classes
:compileTestJava
:processTestResources UP-TO-DATE
:testClasses
:test UP-TO-DATE
:jacocoTestReport SKIPPED

I have only 1 test in the src/test/java location.

Why will it not generate the reports and run? I'm at a loss.


回答1:


Remove the wrong include statement in your test configuration.

That seems to cause the test task to always be up-to-date (not executing any test as the include pattern isn't matched)

The jacocoTestReport will be skipped if there's no execution data available that is needed to generate the report. This execution data should be generated while the test task is executed. In your example we see that the test task is always marked as up-to-date (because of the invalid include statement) causing the build to never produce any input for the jacocoTestReport task.



来源:https://stackoverflow.com/questions/44553349/gradle-skipping-jacoco-coverage-plugin

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!