Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle skipping jacoco coverage plugin

Tags:

gradle

jacoco

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.

like image 815
Justin Avatar asked Jun 17 '26 20:06

Justin


1 Answers

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.

like image 76
Rene Groeschke Avatar answered Jun 20 '26 10:06

Rene Groeschke



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!