Basically the only way to re-route is to re-build the JacocoReportBase.classDirectories object from scratch.

tasks.withType<JacocoReportBase>().configureEach {
    classDirectories.setFrom(sourceSets.main.map {
        it.output.asFileTree.matching {
            exclude("**/build/**")
        }
    })
}

or

reporting {
    reports {
        withType<JacocoCoverageReport>().configureEach {
            reportTask.configure {
                classDirectories.setFrom(sourceSets.main.map {
                    it.output.asFileTree.matching {
                        exclude("**/build/**")
                    }
                })
            }
        }
    }
}

when using the reporting extension.