SchildiChat-android/coverage.gradle
Michael Kaye 9fe04ac5b8 Remove exclusions (for now).
We can merge this PR without and re-add afterwards the only ones we want.
2022-03-03 20:26:33 +00:00

72 lines
2.7 KiB
Groovy

def excludes = [ ]
def initializeReport(report, projects, classExcludes) {
projects.each { project -> project.apply plugin: 'jacoco' }
report.executionData { fileTree(rootProject.rootDir.absolutePath).include("**/build/jacoco/*.exec") }
report.reports {
xml.enabled true
html.enabled true
csv.enabled false
}
gradle.projectsEvaluated {
def androidSourceDirs = []
def androidClassDirs = []
projects.each { project ->
switch (project) {
case { project.plugins.hasPlugin("com.android.application") }:
androidClassDirs.add("${project.buildDir}/tmp/kotlin-classes/debug")
androidSourceDirs.add("${project.projectDir}/src/main/kotlin")
androidSourceDirs.add("${project.projectDir}/src/main/java")
break
case { project.plugins.hasPlugin("com.android.library") }:
androidClassDirs.add("${project.buildDir}/tmp/kotlin-classes/release")
androidSourceDirs.add("${project.projectDir}/src/main/kotlin")
androidSourceDirs.add("${project.projectDir}/src/main/java")
break
default:
report.sourceSets project.sourceSets.main
}
}
report.sourceDirectories.setFrom(report.sourceDirectories + files(androidSourceDirs))
def classFiles = androidClassDirs.collect { files(it).files }.flatten()
report.classDirectories.setFrom(files((report.classDirectories.files + classFiles).collect {
fileTree(dir: it, excludes: classExcludes)
}))
}
}
def collectProjects(predicate) {
return subprojects.findAll { it.buildFile.isFile() && predicate(it) }
}
//task unitCodeCoverageReport(type: JacocoReport) {
// outputs.upToDateWhen { false }
// rootProject.apply plugin: 'jacoco'
// def excludedProjects = [
// 'olm-stub',
// 'test-harness'
// ]
// def projects = collectProjects { !excludedProjects.contains(it.name) }
// dependsOn { ["app:assembleDebug"] + projects*.test }
// initializeReport(it, projects, excludes)
//}
//
//task harnessCodeCoverageReport(type: JacocoReport) {
// outputs.upToDateWhen { false }
// rootProject.apply plugin: 'jacoco'
// def projects = collectProjects { true }
// dependsOn { ["app:assembleDebug", project(":test-harness").test] }
// initializeReport(it, projects, excludes)
//}
task allCodeCoverageReport(type: JacocoReport) {
outputs.upToDateWhen { false }
rootProject.apply plugin: 'jacoco'
def projects = collectProjects { true }
dependsOn { projects*.test }
initializeReport(it, projects, excludes)
}