2022-02-09 22:45:05 +01:00
|
|
|
apply plugin: 'jacoco'
|
|
|
|
|
|
|
|
jacoco {
|
2023-07-19 13:53:43 +02:00
|
|
|
toolVersion '0.8.10'
|
2022-02-09 22:45:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
project.afterEvaluate {
|
|
|
|
def variants = ["debug", "fullDebug"]
|
|
|
|
|
2022-02-10 17:05:17 +01:00
|
|
|
tasks.create(name: "jacocoAllDebugReport", type: JacocoReport) {
|
2022-02-09 22:45:05 +01:00
|
|
|
|
|
|
|
group = "Reporting"
|
|
|
|
description = "Generate overall Jacoco coverage report for the debug build."
|
|
|
|
|
|
|
|
reports {
|
|
|
|
html.required.set(true)
|
|
|
|
xml.required.set(true)
|
|
|
|
}
|
|
|
|
|
|
|
|
def excludes = [
|
2023-08-27 17:43:30 +02:00
|
|
|
'**/di/*Module.class',
|
|
|
|
'**/di/*Component.class',
|
|
|
|
'**/com/jjoe64/**/*.*',
|
2022-02-09 22:45:05 +01:00
|
|
|
'**/R.class',
|
|
|
|
'**/R$*.class',
|
|
|
|
'**/BuildConfig.*',
|
|
|
|
'**/Manifest*.*',
|
|
|
|
'**/*Test*.*',
|
|
|
|
'android/**/*.*',
|
|
|
|
'androidx/**/*.*',
|
|
|
|
'**/*$ViewInjector*.*',
|
|
|
|
'**/*Dagger*.*',
|
|
|
|
'**/*MembersInjector*.*',
|
|
|
|
'**/*_Factory.*',
|
|
|
|
'**/*_Provide*Factory*.*',
|
|
|
|
'**/*_ViewBinding*.*',
|
|
|
|
'**/AutoValue_*.*',
|
|
|
|
'**/R2.class',
|
|
|
|
'**/R2$*.class',
|
|
|
|
'**/*Directions$*',
|
|
|
|
'**/*Directions.*',
|
2022-11-03 22:27:27 +01:00
|
|
|
'**/*Binding.*',
|
|
|
|
'**/BR.class'
|
2022-02-09 22:45:05 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
def jClasses = subprojects.collect { proj ->
|
|
|
|
variants.collect { variant ->
|
|
|
|
"${proj.buildDir}/intermediates/javac/$variant/classes"
|
|
|
|
}
|
|
|
|
}.flatten()
|
|
|
|
def kClasses = subprojects.collect { proj ->
|
|
|
|
variants.collect { variant ->
|
|
|
|
"${proj.buildDir}/tmp/kotlin-classes/$variant"
|
|
|
|
}
|
|
|
|
}.flatten()
|
|
|
|
|
|
|
|
def javaClasses = jClasses.collect { path ->
|
|
|
|
fileTree(dir: path, excludes: excludes)
|
|
|
|
}
|
|
|
|
def kotlinClasses = kClasses.collect { path ->
|
|
|
|
fileTree(dir: path, excludes: excludes)
|
|
|
|
}
|
|
|
|
|
|
|
|
classDirectories.from = files([javaClasses, kotlinClasses])
|
|
|
|
def sources = subprojects.collect { proj ->
|
|
|
|
variants.collect { variant ->
|
|
|
|
["${proj.projectDir}/src/main/java", "${proj.projectDir}/src/main/kotlin",
|
|
|
|
"${proj.projectDir}/src/$variant/java", "${proj.projectDir}/src/$variant/kotlin"]
|
|
|
|
}.flatten()
|
|
|
|
}.flatten()
|
|
|
|
sourceDirectories.from = files(sources)
|
|
|
|
|
|
|
|
def executions = subprojects.collect { proj ->
|
|
|
|
variants.collect { variant ->
|
2023-07-19 13:53:43 +02:00
|
|
|
def path = "${proj.buildDir}/outputs/unit_test_code_coverage/${variant}UnitTest/test${variant.capitalize()}UnitTest.exec"
|
|
|
|
// printf('Collecting execution data from: %s\n', path)
|
2022-02-09 22:45:05 +01:00
|
|
|
if ((new File(path)).exists()) path else null
|
|
|
|
}
|
|
|
|
}.flatten()
|
|
|
|
executions.removeAll([null])
|
|
|
|
|
|
|
|
executionData.from = files(executions)
|
|
|
|
}
|
|
|
|
}
|