java.lang.ClassNotFoundException: org.jacoco.ant.MergeTask


(Yi Cheng) #1

Hi,

I have an Android project with gradle 2.14.1 and want to set up jacoco integration. For the part invoking jacocoTestReport, it works. However, when it comes to jacocoMerge it starts to throw classNotFoundException.

apply plugin: 'jacoco'

task merge(type: JacocoMerge) {
    group = "Reporting"
    description = "Generate Jacoco coverage reports after other individual jacoco tests."

    destinationFile = file("$buildDir/jacoco/jacocoLibSummary.exec")
    executionData = files()
    jacocoClasspath = files()
}

./gradlew tasks works, and shows merge task.
but if I want to invoke merge task, it has the following error:

$ ./gradlew merge
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html.
Incremental java compilation is an incubating feature.
:merge FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':merge'.
> java.lang.ClassNotFoundException: org.jacoco.ant.MergeTask
...

According to https://docs.gradle.org/2.14/userguide/jacoco_plugin.html, jacoco plugin should pull in JacocoAnt as well, so I was wondering what part I could be missing.

I’ve tried adding the following, but still no luck.

buildscript{
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'org.jacoco:org.jacoco.ant:0.7.8'
    }
}

Edit: upgraded the dummy project to gradle 3.3, and same issue.