2022-02-24 22:55:56 +01:00
|
|
|
def excludes = [
|
|
|
|
// DI graph
|
|
|
|
'**/*Module.*',
|
|
|
|
'**/*Module*.*',
|
|
|
|
|
|
|
|
// Android composables
|
|
|
|
'**/*Screen*',
|
|
|
|
'**/components/*',
|
|
|
|
'**/*Compose*.*',
|
|
|
|
|
|
|
|
// Android framework
|
|
|
|
'**/*Activity*',
|
|
|
|
'**/*AndroidService*',
|
|
|
|
'**/*Application*',
|
|
|
|
|
|
|
|
// Generated
|
|
|
|
'**/*serializer*',
|
|
|
|
'**/*Serializer*',
|
|
|
|
"**/*request/*Companion*.*",
|
|
|
|
'**/*QueriesImpl*',
|
|
|
|
'**/*Db*',
|
|
|
|
'**/Select*',
|
|
|
|
|
|
|
|
// Tmp until serializationx can ignore generated
|
|
|
|
'**/Api*',
|
|
|
|
]
|
|
|
|
|
|
|
|
def initializeReport(report, projects, classExcludes) {
|
2022-02-27 23:55:42 +01:00
|
|
|
projects.each { project -> project.apply plugin: 'jacoco' }
|
|
|
|
report.executionData { fileTree(rootProject.rootDir.absolutePath).include("**/build/jacoco/*.exec") }
|
2022-02-24 22:55:56 +01:00
|
|
|
|
2022-02-27 23:55:42 +01:00
|
|
|
report.reports {
|
|
|
|
xml.enabled true
|
|
|
|
html.enabled true
|
|
|
|
csv.enabled false
|
2022-02-24 22:55:56 +01:00
|
|
|
}
|
|
|
|
|
2022-02-27 23:55:42 +01:00
|
|
|
gradle.projectsEvaluated {
|
|
|
|
def androidSourceDirs = []
|
|
|
|
def androidClassDirs = []
|
|
|
|
|
|
|
|
projects.each { project ->
|
2022-02-24 22:55:56 +01:00
|
|
|
switch (project) {
|
2022-02-27 23:55:42 +01:00
|
|
|
case { project.plugins.hasPlugin("com.android.application") }:
|
|
|
|
androidClassDirs.add("${project.buildDir}/tmp/kotlin-classes/debug")
|
|
|
|
androidSourceDirs.add("${project.projectDir}/src/main/kotlin")
|
2022-02-24 22:55:56 +01:00
|
|
|
break
|
2022-02-27 23:55:42 +01:00
|
|
|
case { project.plugins.hasPlugin("com.android.library") }:
|
|
|
|
androidClassDirs.add("${project.buildDir}/tmp/kotlin-classes/release")
|
|
|
|
androidSourceDirs.add("${project.projectDir}/src/main/kotlin")
|
2022-02-24 22:55:56 +01:00
|
|
|
break
|
|
|
|
default:
|
2022-02-27 23:55:42 +01:00
|
|
|
report.sourceSets project.sourceSets.main
|
2022-02-24 22:55:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-27 23:55:42 +01:00
|
|
|
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)
|
|
|
|
}))
|
2022-02-24 22:55:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def collectProjects(predicate) {
|
|
|
|
return subprojects.findAll { it.buildFile.isFile() && predicate(it) }
|
|
|
|
}
|
|
|
|
|
2022-02-27 23:55:42 +01:00
|
|
|
//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)
|
|
|
|
//}
|
2022-02-24 22:55:56 +01:00
|
|
|
|
|
|
|
task allCodeCoverageReport(type: JacocoReport) {
|
2022-02-27 23:55:42 +01:00
|
|
|
outputs.upToDateWhen { false }
|
2022-02-24 22:55:56 +01:00
|
|
|
rootProject.apply plugin: 'jacoco'
|
2022-03-13 15:15:24 +01:00
|
|
|
def projects = collectProjects { !it.name.contains("stub") }
|
2022-02-27 23:55:42 +01:00
|
|
|
dependsOn { ["app:assembleDebug"] + projects*.test }
|
2022-02-24 22:55:56 +01:00
|
|
|
initializeReport(it, projects, excludes)
|
|
|
|
}
|