sri anoop
sri anoop

Reputation: 1

Gradle project JaCoCo plugin installation in offline mode is throwing error

I have a gradle project in a server which doesn't have internet connectivity and I need to add JaCoCo plugin there and then I need to generate code coverage report for the JUnit tests which runs under test task.

To achieve this I have downloaded all the required JaCoCo plugin jars(org.jacoco.core-0.8.11.jar, org.jacoco.agent-0.8.11.jar, org.jacoco.report-0.8.11.jar, org.jacoco.ant-0.8.11.jar) and placed them in the lib folder of the Gradle project and added the dependency in the build.gradle for the JaCoCo to get the jars from the lib folder.

It is failing to generate the JaCoCo report because it is unable to find org/jacoco/report/IReportGroupVisitor class... But I have that report jar inside the lib folder still throwing this error.

I'm using gradle 8.1.1 and JaCoCo 0.8.11 version.

build.gradle file

buildscript {
    repositories {
        flatDir {
            dirs 'src/main/webapp/WEB-INF/lib' // Directory where the JaCoCo plugin JARs are located
        }
    }
    dependencies {
        classpath files('src/main/webapp/WEB-INF/lib/org.jacoco.core-0.8.11.jar',
                       'src/main/webapp/WEB-INF/lib/org.jacoco.agent-0.8.11.jar',
                       'src/main/webapp/WEB-INF/lib/org.jacoco.ant-0.8.11.jar',
                       'src/main/webapp/WEB-INF/lib/org.jacoco.report-0.8.11.jar')
    }
}

plugins {
    id 'java-library'
    id 'java'
}

apply plugin: 'jacoco'

java {
    sourceCompatibility = '1.8'
}

repositories {
    //mavenCentral()
      flatDir {
        dirs 'src/main/webapp/WEB-INF/lib'
    }
}

dependencies {
    implementation fileTree('src/main/webapp/WEB-INF/lib')
    files('src/main/webapp/WEB-INF/lib/org.jacoco.core-0.8.11.jar' , 'src/main/webapp/WEB-INF/lib/org.jacoco.report-0.8.11.jar')
    jacocoAgent files('src/main/webapp/WEB-INF/lib/org.jacoco.agent-0.8.11.jar')
    jacocoAnt files('src/main/webapp/WEB-INF/lib/org.jacoco.ant-0.8.11.jar')
    implementation files('src/main/webapp/WEB-INF/lib/org.jacoco.core-0.8.11.jar' , 'src/main/webapp/WEB-INF/lib/org.jacoco.report-0.8.11.jar')
    //jacocoReport files('src/main/webapp/WEB-INF/lib/org.jacoco.report-0.8.11.jar')
}

tasks.withType(War).configureEach {
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

jacoco {
    toolVersion = "0.8.11" // Specify JaCoCo version
}

test {
    useJUnit()
    ignoreFailures = true
    jacoco {
        enabled = true
    }
}

jacocoTestReport {
    enabled = true
    reports {
        xml {
        enabled true // Enable XML report
        }
        html {
            enabled true // Enable HTML report
        }
    }
}

tasks.named('test').configure {
    finalizedBy 'jacocoTestReport'
}

jacocoTestReport.dependsOn(test)

configurations.all {
    exclude group: 'org.jacoco', module: 'org.jacoco.agent'
}

FAILURE: Build failed with an exception.

org/jacoco/report/IReportGroupVisitor

Can someone help in fixing this error in offline mode

Upvotes: 0

Views: 146

Answers (0)

Related Questions