-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
103 lines (92 loc) · 3.11 KB
/
build.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
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
jacoco_version = "0.8.7"
}
dependencies {
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.42'
}
}
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'org.jetbrains.kotlin.android' version '1.7.0' apply false
}
apply plugin: 'jacoco'
jacoco {
toolVersion = jacoco_version
}
allprojects {
configurations.all {
resolutionStrategy {
eachDependency { details ->
if ("org.jacoco" == details.requested.group) {
details.useVersion jacoco_version
}
}
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
def coverageExclusion = [
'**/R.class',
'**/R$*.class',
'**/BuildConfig.class',
'**/Manifest.class',
'**/Manifest$*.class',
'**/*$InjectAdapter.class',
'**/*$ModuleAdapter.class',
'**/*$ViewInjector*.class',
'**/*_MembersInjector.class',
'**/Dagger*Component.class',
'**/Dagger*Component$Builder.class',
'**/*Module_*Factory.class',
'**/*$ViewInjector*.*',
'**/*$ViewBinder*.*',
'**/*Module.*',
'**/*Application.*',
// Necessary for Workaround #3 (see README.md)
'**/*Hilt*',
'**/*ViewModelLazy*',
'**/*Fragment.special*',
'**/*_Factory*',
'**/*_Component*',
'**/*_Generated*',
]
def coverageKotlinClassDirectories = [
fileTree(dir: project.projectDir,
include: "**/build/tmp/kotlin-classes/debug*/**",
exclude: "**/build/tmp/kotlin-classes/debug*Test/**")
]
def workaroundClassDirectories = [
fileTree(dir: project.projectDir,
include: "**/build/intermediates/asm_instrumented_project_classes/debug/")
]
def coverageJavaClassDirectories = [
fileTree(dir: project.projectDir,
include: "**/build/intermediates/classes/debug*/**",
exclude: "**/build/intermediates/classes/debug*Test/**")
]
task rootCodeCoverageReport(
type: JacocoReport,
dependsOn: ["app:createDebugAndroidTestCoverageReport",
"app:testDebugUnitTest"]
) {
group = "Reporting"
description = "Generate Jacoco coverage reports after running tests."
reports {
xml.required = true
html.required = true
}
sourceDirectories.from = fileTree(dir: project.projectDir, include: "**/src/main")
classDirectories.from = files(coverageJavaClassDirectories, coverageKotlinClassDirectories).collect {
fileTree(dir: it, include: "**/*.class", exclude: coverageExclusion)
}
// Uncomment for Workaround #3 (see README.md)
// classDirectories.from = files(coverageJavaClassDirectories, workaroundClassDirectories).collect {
// fileTree(dir: it, include: "**/*.class", exclude: coverageExclusion)
// }
executionData.from = fileTree(dir: project.projectDir, includes: ["**/*.exec", "**/*.ec"])
outputs.upToDateWhen { false }
}