0

I've done gradle migration from gradle 3.5 to gradle 4.6. After migration exec files have stopped generated. '/build' folder doesn't contain 'jacoco' folder. If I run gradle command with -- debug it writes in log :

[org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter] Skipping task ':common:jacocoTestReport' as task onlyIf is false.

Here is part of gradle script:

subprojects {
apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'idea'
...
jacocoTestReport {
    reports {
        xml.enabled true
        csv.enabled false
    }
    afterEvaluate {
        classDirectories = files(classDirectories.files.collect {
            fileTree(dir: it,
                    exclude: ['**/dto/**', '**/endpoint/**','**/enpoints/**', '**/spring/**',
                              '**/servlet/**','**/handler/**', '**/jpa/**', '**/filter/**', '**/events/**', '**/dao/**',
                              '**/exception/**', '**/http/**', '**/jdbc/**', '**/bigquery/**', '**/enums/**',
                              '**/repository/**', '**/combination/**', '**/datastore/**', '**/cassandra/**',
                              '**/google/**', '**/exceptions/**', '**/logging/**', '**/JavaGeneratedContext.java', '**/Q*.java'])
        })
    }
}

test {
    enabled = !skipTests
    allJvmArgs = [
        '-Dfile.encoding=utf-8'
    ]
    useJUnit {
        excludeCategories 'com.severn.common.test.IntegrationTest'
    }
    /*jacoco {
        enabled = true
        destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
    }*/
    finalizedBy jacocoTestReport
}

...

}
  • What is the gradle command line you are using ? – ToYonos May 02 '18 at 08:57
  • gradle clean build – Hunar Letsko May 03 '18 at 09:35
  • Hunar, can you share the detailed (`--debug`) output for the `test` task. Is that running or not. Otherwise for the `test`s to run. This error is simply because you don't have .exec file `destinationFile` variable location and jacocoTestReport is looking for that, thus the error. – AKS May 08 '18 at 18:39
  • Also look into the latest Gradle version's distro (full zip/tar) to see examples of `Jacoco` in a Java project, see if something has changed that you may need to include now for creating the .exec file(s) – AKS May 08 '18 at 18:54

1 Answers1

0

Make sure:

1) Your debug info is enabled during compile in your top level Gradle file (allprojects { ... } ). See here for more info: Jacoco Unit and Integration Tests coverage - individual and overall

   tasks.withType(Compile) {
     options.debug = true
     options.compilerArgs = ["-g"]
   }

2) Try removing the whole Jacoco configuration from the test task (make sure you place the .exec file if generated in the default location where jacocoTestReport task expects it). Make sure test task is running (and not getting excluded somehow). For testing purpose (to narrow down this .exec not getting created issue), you can force jacocoTestReport task to dependOn test task.

tasks.withType(Test) {enabled = true}

3) See latest Gradle 4.6 bundle (tar/zip) for Jacoco examples for a Java single/multi level project to get hint.

PS: Default JaCoCo version upgraded to 0.8.0 See if forcing this version within jacoco block helps.

https://docs.gradle.org/4.6/release-notes.html The JaCoCo plugin has been upgraded to use JaCoCo version 0.8.0 by default.

AKS
  • 16,482
  • 43
  • 166
  • 258