2022-03-03 23:26:33 +03:00
|
|
|
def excludes = [ ]
|
2022-03-03 13:40:11 +03:00
|
|
|
|
|
|
|
def initializeReport(report, projects, classExcludes) {
|
|
|
|
projects.each { project -> project.apply plugin: 'jacoco' }
|
2022-05-25 14:38:37 +03:00
|
|
|
report.executionData { fileTree(rootProject.rootDir.absolutePath).include(
|
|
|
|
"**/build/outputs/unit_test_code_coverage/**/*.exec",
|
|
|
|
"**/build/outputs/code_coverage/**/coverage.ec"
|
|
|
|
) }
|
2022-03-03 13:40:11 +03:00
|
|
|
|
|
|
|
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") }:
|
2022-04-13 16:17:24 +03:00
|
|
|
androidClassDirs.add("${project.buildDir}/tmp/kotlin-classes/gplayDebug")
|
2022-05-25 14:38:37 +03:00
|
|
|
androidSourceDirs.add("${project.buildDir}/generated/source/kapt/gplayDebug")
|
2022-03-03 13:40:11 +03:00
|
|
|
androidSourceDirs.add("${project.projectDir}/src/main/kotlin")
|
|
|
|
androidSourceDirs.add("${project.projectDir}/src/main/java")
|
|
|
|
break
|
|
|
|
case { project.plugins.hasPlugin("com.android.library") }:
|
2022-03-04 18:03:12 +03:00
|
|
|
androidClassDirs.add("${project.buildDir}/tmp/kotlin-classes/debug")
|
2022-05-25 14:38:37 +03:00
|
|
|
androidSourceDirs.add("${project.buildDir}/generated/source/kapt/debug")
|
2022-03-03 13:40:11 +03:00
|
|
|
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) }
|
|
|
|
}
|
|
|
|
|
2022-05-25 14:38:37 +03:00
|
|
|
task theCodeCoverageReport(type: JacocoReport) {
|
2022-03-03 13:40:11 +03:00
|
|
|
outputs.upToDateWhen { false }
|
|
|
|
rootProject.apply plugin: 'jacoco'
|
2022-05-25 14:38:37 +03:00
|
|
|
tasks.withType(Test) {
|
|
|
|
jacoco.includeNoLocationClasses = true
|
|
|
|
}
|
|
|
|
def projects = collectProjects { ['vector','matrix-sdk-android'].contains(it.name) }
|
|
|
|
dependsOn {
|
|
|
|
[':matrix-sdk-android:testDebugUnitTest'] +
|
|
|
|
[':vector:testGplayDebugUnitTest'] +
|
|
|
|
[':matrix-sdk-android:connectedDebugAndroidTest']
|
|
|
|
}
|
2022-03-03 13:40:11 +03:00
|
|
|
initializeReport(it, projects, excludes)
|
|
|
|
}
|