-
Notifications
You must be signed in to change notification settings - Fork 12
/
jacoco.gradle
140 lines (125 loc) · 4.91 KB
/
jacoco.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
apply plugin: 'jacoco'
jacoco {
toolVersion = "$jacocoVersion"
}
// Force Jacoco Version
subprojects {
configurations.configureEach {
resolutionStrategy {
eachDependency { details ->
if ('org.jacoco' == details.requested.group) {
details.useVersion "$jacocoVersion"
}
}
}
}
}
project.afterEvaluate { project ->
tasks.withType(Test).configureEach {
jacoco.includeNoLocationClasses = true
jacoco.excludes = ['jdk.internal.*']
}
final buildType = "debug"
final variant = "$buildType"
final taskName = "jacocoTest${variant.capitalize()}UnitTestReport"
tasks.register(taskName, JacocoReport) {
dependsOn "test${variant.capitalize()}UnitTest"
reports {
csv.required = false
xml.required = true
html.required = true
}
final fileFilter = [
// data binding
'**/databinding/*',
'android/databinding/**/*.class',
'**/android/databinding/*Binding.class',
'**/android/databinding/*',
'**/androidx/databinding/*',
'**/BR.*',
// android
'**/R.class',
'**/R$*.class',
'**/BuildConfig.*',
'**/Manifest*.*',
'**/*Test*.*',
'android/**/*.*',
// kotlin
'**/*MapperImpl*.*',
'**/*$ViewInjector*.*',
'**/*$ViewBinder*.*',
'**/BuildConfig.*',
'**/*Component*.*',
'**/*BR*.*',
'**/Manifest*.*',
'**/*$Lambda$*.*',
'**/*Companion*.*',
'**/*Module*.*',
'**/*Dagger*.*',
'**/*Hilt*.*',
'**/*MembersInjector*.*',
'**/*_MembersInjector.class',
'**/*_Factory*.*',
'**/*_Provide*Factory*.*',
'**/*Extensions*.*',
// sealed and data classes
'**/*$Result.*',
'**/*$Result$*.*',
// adapters generated by moshi
'**/*JsonAdapter.*',
// Hilt
'**/*Module.kt',
'**/di/**',
'dagger.hilt.internal/*',
'hilt_aggregated_deps/*',
'**/*$Result.*', /* filtering `sealed` and `data` classes */
'**/*$Result$*.*',/* filtering `sealed` and `data` classes */
'**/*Args*.*', /* filtering Navigation Component generated classes */
'**/*Directions*.*', /* filtering Navigation Component generated classes */
'**/*inlined*.class', /* filtering inlined classes */
'**/*Module_*Factory.class',
'**/*Application.*',
'**/*Activity.*',
'**/*Fragment.*',
'**/*View.*',
'**/*MenuProvider.*',
'**/*ViewExtensions*',
'**/*Decoration.*',
'**/*ViewHolder.*',
'**/*Adapter.*',
'**/*Listener.*',
'**/di/**',
'**/*Fragment+*.*',
'**/*View+*.*',
'**/*Presenter+*.*',
'**/*Presenter.*',
'**/*ViewModelFactory.*',
'**/RuntimeTypeAdapterFactory.*',
'**/*BuilderProvider.*',
'**/composables/**',
'**/BuildHelper.*',
'**/BuildConfigHelper.*',
'**/*ViewModelFactory.*',
'**/*ScreenEvent.*',
'**/core/Airwallex.kt',
'**/card/AirwallexSecurityConnector.kt',
'**/AirwallexStarter.kt',
'**/*InputLayout.kt',
'**/*EditText.kt',
'**/view/CardWidget.kt',
'**/paymentacceptance/**',
'security-3ds/**'
]
final androidKotlinTree = fileTree(dir: "${project.buildDir}/tmp/kotlin-classes/${variant}", excludes: fileFilter)
final kotlinTree = fileTree(dir: "${project.buildDir}/classes/kotlin/main", excludes: fileFilter)
final javacTree = fileTree(dir: "${project.buildDir}/intermediates/javac/${variant}/classes", excludes: fileFilter)
final mainSrc = "${project.projectDir}/src/main/java"
final buildTypeSrc = "${project.projectDir}/src/${buildType}/java"
sourceDirectories.setFrom files([mainSrc, buildTypeSrc])
classDirectories.setFrom files([androidKotlinTree, kotlinTree, javacTree])
executionData.setFrom fileTree(dir: project.buildDir, includes: [
"jacoco/test${variant.capitalize()}UnitTest.exec",
"outputs/unit_test_code_coverage/${variant}UnitTest/test${variant.capitalize()}UnitTest.exec"
])
}
}