jacocoTest exclusion has no effect

108 Views Asked by At

I have a gradle project and I want to exclude some directories from TC coverage. This is what I am giving in the task

jacocoTestReport {
reports {
    xml.enabled true
    csv.enabled false
    html.enabled true
}

afterEvaluate {
    classDirectories.setFrom(files(classDirectories.files.collect {
        fileTree(dir: it).exclude(
            // define here
            'com/this/that'
        )
    }))
}

}

However the classes still shows up in the coverage. What am I missing?

1

There are 1 best solutions below

3
lance-java On

afterEvaluate runs in Gradle's configuration phase which is before any tasks have executed and before any classes have been compiled (see build phases)

I'm guessing you want something like

test {
   jacoco {
      excludes = ['com/this/that/*'] 
   } 
}