Good morning, I would like to take this opportunit...
# community-support
b
Good morning, I would like to take this opportunity to thank you all for this great platform. I have one issue blocking me currently in integrating JaCoCo with my android kotlin project as I'm getting this error
Failed to notify project evaluation listener.
> 'void org.gradle.api.reporting.ConfigurableReport.setEnabled(boolean)' > Could not get unknown property 'sourceDirectories' for project ':app' of type org.gradle.api.Project.
here is my JaCoCo.gradle file
Copy code
apply plugin: 'jacoco'

jacoco {
    toolVersion = "0.8.11"
//    reportsDir = layout.buildDirectory.dir("reports/jacoco")
}

private static boolean isAndroidModule(Project project) {
    boolean isAndroidLibrary = project.plugins.hasPlugin('com.android.library')
    boolean isAndroidApp = project.plugins.hasPlugin('com.android.application')
    return isAndroidLibrary || isAndroidApp
}
afterEvaluate { project ->
    if (isAndroidModule(project)) setupAndroidReporting()
    else setupKotlinReporting()
}
def setupKotlinReporting() {
    jacocoTestReport {
        dependsOn test
        reports {
            xml.required.set(true)
            html.required.set(true)
            html.outputLocation.set(layout.buildDirectory.dir("/coverage-report"))
        }
    }
}
def setupAndroidReporting() {
    tasks.withType(Test).configureEach {
        jacoco.includeNoLocationClasses true
        jacoco.excludes = ["jdk.internal.*"]
        finalizedBy "jacocoTestReport"

    }
    tasks.register("jacocoTestReport", JacocoReport){
        dependsOn "testDebugUnitTest"
        reports {
            xml.required.set(true)
            html.required.set(true)
            csv.required.set(false)
        }
    }
        // Change as needed
        def fileFilter = [
                '**/*App.*',
                '**/*Application.*',
                '**/*Activity.*',
                '**/*Fragment.*',
                '**/*JsonAdapter.*', // adapters generated by Moshi
                '**/di/**',
                '**/*Dagger.*'
        ]
        def debugTree = fileTree(
                dir: "$layout.buildDirectory/tmp/kotlin-classes/debug",
                excludes: fileFilter
        )
        def mainSrc = "$projectDir/src/main/java"
        sourceDirectories.from = files([mainSrc])
        classDirectories.from = files([debugTree])
        executionData.from = fileTree(
                dir: project.layout.buildDirectory,
                includes: [
                        'jacoco/testDebugUnitTest.exec',
                        'outputs/code-coverage/connected/*<http://coverage.ec|coverage.ec>'
                ]
        )
    }
Copy code
------------------------------------------------------------
Gradle 8.3
------------------------------------------------------------

Build time:   2023-08-17 07:06:47 UTC
Revision:     8afbf24b469158b714b36e84c6f4d4976c86fcd5

Kotlin:       1.9.0
Groovy:       3.0.17
Ant:          Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM:          17.0.7 (Oracle Corporation 17.0.7+8-LTS-224)
OS:           Mac OS X 14.5 x86_64