forked from nightscout/AndroidAPS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jacoco_project.gradle
85 lines (73 loc) · 2.68 KB
/
jacoco_project.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
apply plugin: 'jacoco'
jacoco {
toolVersion '0.8.7'
}
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
jacoco.excludes = ['jdk.internal.*']
}
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 = [
'**/R.class',
'**/R$*.class',
'**/BuildConfig.*',
'**/Manifest*.*',
'**/*Test*.*',
'android/**/*.*',
'androidx/**/*.*',
'**/*$ViewInjector*.*',
'**/*Dagger*.*',
'**/*MembersInjector*.*',
'**/*_Factory.*',
'**/*_Provide*Factory*.*',
'**/*_ViewBinding*.*',
'**/AutoValue_*.*',
'**/R2.class',
'**/R2$*.class',
'**/*Directions$*',
'**/*Directions.*',
'**/*Binding.*'
]
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}/jacoco/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)
}
}