2022-06-10 06:58:04 +08:00
|
|
|
def excludes = [
|
|
|
|
// dependency injection graph
|
|
|
|
'**/*Module.*',
|
|
|
|
'**/*Module*.*',
|
|
|
|
|
|
|
|
// Framework entry points
|
|
|
|
'**/*Activity*',
|
|
|
|
'**/*Fragment*',
|
|
|
|
'**/*Application*',
|
2022-07-05 17:17:40 +08:00
|
|
|
'**/*AndroidService*',
|
2022-06-10 06:58:04 +08:00
|
|
|
|
|
|
|
// We would like to exclude android widgets as well but our naming is inconsistent
|
|
|
|
|
|
|
|
// Proof of concept
|
|
|
|
'**/*Login2*',
|
|
|
|
|
|
|
|
// Generated
|
|
|
|
'**/*JsonAdapter*',
|
|
|
|
'**/*Item.*',
|
|
|
|
'**/*$Holder.*',
|
|
|
|
'**/*ViewHolder.*',
|
|
|
|
'**/*View.*',
|
|
|
|
'**/*BottomSheet.*'
|
|
|
|
]
|
2022-03-03 18:40:11 +08:00
|
|
|
|
|
|
|
def initializeReport(report, projects, classExcludes) {
|
|
|
|
projects.each { project -> project.apply plugin: 'jacoco' }
|
|
|
|
|
2022-05-04 22:48:23 +08:00
|
|
|
report.executionData {
|
|
|
|
fileTree(rootProject.rootDir.absolutePath).include(
|
2022-06-14 22:56:16 +08:00
|
|
|
"**/build/**/*.exec",
|
2022-05-04 22:48:23 +08:00
|
|
|
"**/build/outputs/code_coverage/**/coverage.ec",
|
|
|
|
)
|
|
|
|
}
|
2022-03-03 18:40:11 +08: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 21:17:24 +08:00
|
|
|
androidClassDirs.add("${project.buildDir}/tmp/kotlin-classes/gplayDebug")
|
2022-03-03 18:40:11 +08: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 23:03:12 +08:00
|
|
|
androidClassDirs.add("${project.buildDir}/tmp/kotlin-classes/debug")
|
2022-03-03 18:40:11 +08: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-06-14 22:56:16 +08:00
|
|
|
task generateCoverageReport(type: JacocoReport) {
|
2022-03-03 18:40:11 +08:00
|
|
|
outputs.upToDateWhen { false }
|
|
|
|
rootProject.apply plugin: 'jacoco'
|
2022-06-14 22:56:16 +08:00
|
|
|
def projects = collectProjects { ['vector', 'matrix-sdk-android'].contains(it.name) }
|
2022-03-03 18:40:11 +08:00
|
|
|
initializeReport(it, projects, excludes)
|
|
|
|
}
|
2022-06-14 22:56:16 +08:00
|
|
|
|
|
|
|
task unitTestsWithCoverage(type: GradleBuild) {
|
|
|
|
// the 7.1.3 android gradle plugin has a bug where enableTestCoverage generates invalid coverage
|
|
|
|
startParameter.projectProperties.coverage = [enableTestCoverage: false]
|
|
|
|
tasks = [':vector:testGplayDebugUnitTest', ':matrix-sdk-android:testDebugUnitTest']
|
|
|
|
}
|
|
|
|
|
|
|
|
task instrumentationTestsWithCoverage(type: GradleBuild) {
|
|
|
|
startParameter.projectProperties.coverage = [enableTestCoverage: true]
|
2022-06-15 01:35:22 +08:00
|
|
|
startParameter.projectProperties['android.testInstrumentationRunnerArguments.notPackage'] = 'im.vector.app.ui'
|
2022-06-14 22:56:16 +08:00
|
|
|
tasks = [':vector:connectedGplayDebugAndroidTest', 'matrix-sdk-android:connectedDebugAndroidTest']
|
|
|
|
}
|