jacoco_project -> jacoco_aggregation.gradle.kts
This commit is contained in:
parent
b6f2ab2d21
commit
5af396b5b0
3 changed files with 85 additions and 86 deletions
|
@ -106,8 +106,8 @@ allprojects {
|
|||
apply(plugin = "jacoco")
|
||||
}
|
||||
|
||||
// Setup all al reports aggregation
|
||||
apply(from = "jacoco_project.gradle")
|
||||
// Setup all reports aggregation
|
||||
apply(from = "jacoco_aggregation.gradle.kts")
|
||||
|
||||
tasks.register<Delete>("clean").configure {
|
||||
delete(rootProject.buildDir)
|
||||
|
|
83
jacoco_aggregation.gradle.kts
Normal file
83
jacoco_aggregation.gradle.kts
Normal file
|
@ -0,0 +1,83 @@
|
|||
apply(plugin = "jacoco")
|
||||
|
||||
project.afterEvaluate {
|
||||
val variants = listOf("debug", "fullDebug")
|
||||
|
||||
tasks.register<JacocoReport>(name = "jacocoAllDebugReport") {
|
||||
|
||||
group = "Reporting"
|
||||
description = "Generate overall Jacoco coverage report for the debug build."
|
||||
|
||||
reports {
|
||||
html.required.set(true)
|
||||
xml.required.set(true)
|
||||
}
|
||||
|
||||
val excludes = listOf(
|
||||
"**/di/*Module.class",
|
||||
"**/di/*Component.class",
|
||||
"**/com/jjoe64/**/*.*",
|
||||
"**/R.class",
|
||||
"**/R$*.class",
|
||||
"**/BuildConfig.*",
|
||||
"**/Manifest*.*",
|
||||
"**/*Test*.*",
|
||||
"android/**/*.*",
|
||||
"androidx/**/*.*",
|
||||
"**/*\$ViewInjector*.*",
|
||||
"**/*Dagger*.*",
|
||||
"**/*MembersInjector*.*",
|
||||
"**/*_Factory.*",
|
||||
"**/*_Provide*Factory*.*",
|
||||
"**/*_ViewBinding*.*",
|
||||
"**/AutoValue_*.*",
|
||||
"**/R2.class",
|
||||
"**/R2$*.class",
|
||||
"**/*Directions$*",
|
||||
"**/*Directions.*",
|
||||
"**/*Binding.*",
|
||||
"**/BR.class"
|
||||
)
|
||||
|
||||
val classesDirectories = mutableListOf<String>().also {
|
||||
subprojects.forEach { proj ->
|
||||
variants.forEach { variant ->
|
||||
it.add("${proj.buildDir}/intermediates/javac/$variant/classes")
|
||||
it.add("${proj.buildDir}/tmp/kotlin-classes/$variant")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val classes = HashSet<ConfigurableFileTree>().also {
|
||||
classesDirectories.forEach { path ->
|
||||
it.add(fileTree(path) { exclude(excludes) })
|
||||
}
|
||||
}
|
||||
|
||||
classDirectories.setFrom(files(listOf(classes)))
|
||||
|
||||
val sources = mutableListOf<String>().also {
|
||||
subprojects.forEach { proj ->
|
||||
variants.forEach { variant ->
|
||||
it.add("${proj.projectDir}/src/main/java")
|
||||
it.add("${proj.projectDir}/src/main/kotlin")
|
||||
it.add("${proj.projectDir}/src/$variant/java")
|
||||
it.add("${proj.projectDir}/src/$variant/kotlin")
|
||||
}
|
||||
}
|
||||
}
|
||||
sourceDirectories.setFrom(files(sources))
|
||||
|
||||
val executions = mutableListOf<String>().also {
|
||||
subprojects.forEach { proj ->
|
||||
variants.forEach { variant ->
|
||||
val path = "${proj.buildDir}/outputs/unit_test_code_coverage/${variant}UnitTest/test${variant.replaceFirstChar(Char::titlecase)}UnitTest.exec"
|
||||
// printf("Collecting execution data from: %s\n", path)
|
||||
if ((File(path)).exists()) it.add(path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
executionData.setFrom(files(executions))
|
||||
}
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
apply plugin: 'jacoco'
|
||||
|
||||
jacoco {
|
||||
toolVersion '0.8.10'
|
||||
}
|
||||
|
||||
project.afterEvaluate {
|
||||
def variants = ["debug", "fullDebug"]
|
||||
|
||||
tasks.create(name: "jacocoAllDebugReport", type: JacocoReport) {
|
||||
|
||||
group = "Reporting"
|
||||
description = "Generate overall Jacoco coverage report for the debug build."
|
||||
|
||||
reports {
|
||||
html.required.set(true)
|
||||
xml.required.set(true)
|
||||
}
|
||||
|
||||
def excludes = [
|
||||
'**/di/*Module.class',
|
||||
'**/di/*Component.class',
|
||||
'**/com/jjoe64/**/*.*',
|
||||
'**/R.class',
|
||||
'**/R$*.class',
|
||||
'**/BuildConfig.*',
|
||||
'**/Manifest*.*',
|
||||
'**/*Test*.*',
|
||||
'android/**/*.*',
|
||||
'androidx/**/*.*',
|
||||
'**/*$ViewInjector*.*',
|
||||
'**/*Dagger*.*',
|
||||
'**/*MembersInjector*.*',
|
||||
'**/*_Factory.*',
|
||||
'**/*_Provide*Factory*.*',
|
||||
'**/*_ViewBinding*.*',
|
||||
'**/AutoValue_*.*',
|
||||
'**/R2.class',
|
||||
'**/R2$*.class',
|
||||
'**/*Directions$*',
|
||||
'**/*Directions.*',
|
||||
'**/*Binding.*',
|
||||
'**/BR.class'
|
||||
]
|
||||
|
||||
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 ->
|
||||
def path = "${proj.buildDir}/outputs/unit_test_code_coverage/${variant}UnitTest/test${variant.capitalize()}UnitTest.exec"
|
||||
// printf('Collecting execution data from: %s\n', path)
|
||||
if ((new File(path)).exists()) path else null
|
||||
}
|
||||
}.flatten()
|
||||
executions.removeAll([null])
|
||||
|
||||
executionData.from = files(executions)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue