-
Notifications
You must be signed in to change notification settings - Fork 989
/
jacoco.gradle
87 lines (78 loc) · 3.55 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
apply plugin: 'jacoco'
jacoco {
toolVersion = "$jacoco_version"
}
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
jacoco.excludes = ['jdk.internal.*']
jacoco.dumpOnExit = true
jacoco.classDumpDir = null
}
// Creates tasks based on the application build variant (productFlavor + buildType = variant)
android.applicationVariants.all { variant ->
def variantName = variant.name.capitalize()
def autoGenerated = ['**/R.class',
'**/R$*.class',
'**/Manifest*.*',
'android/**/*.*',
'**/BuildConfig.*',
'**/*$ViewBinder*.*',
'**/*$ViewInjector*.*',
'**/Lambda$*.class',
'**/Lambda.class',
'**/*Lambda.class',
'**/*Lambda*.class',
'**/*Dagger*.*',
'**/*_MembersInjector.class',
'**/Dagger*Component*.class',
'**/Dagger*Subcomponent*.class',
'**/*Subcomponent$Builder.class',
'**/*Module_*Factory.class',
'**/KSApplication.*',
'**/libs/utils/ApplicationLifecycleUtil.*',
'**/libs/utils/ApplicationUtils.*',
'**/libs/recyclerviewpagination/*.*',
'**/ApplicationModule.*',
'**/*Activity*.*',
'**/*Fragment*.*',
'**/*ViewHolder*.*',
'**/*Toolbar*.*',
'**/*Dialog*.*',
'**/ui/*.*',
'**/ui/compose/*.*',
'**/ui/compose/designsystem/*.*',
'**/ui/views/*.*',
'**/ui/adapters/*.*',
'**/ui/adapters/data/*.*',
'**/ui/adapters/projectcampaign/*.*',
'**/databinding/*.*',
'**/mock/*.*',
'**/mock/factories/*.*',
'**/services/*.*',
'**/firebase/*.*',
'**/fragment/*.*']
/**
* Generates Jacoco coverage reports based off the unit tests.
*/
task("jacoco${variantName}Report", type: JacocoReport, dependsOn: "test${variantName}UnitTest") {
group 'Reporting'
description "Generate ${variantName} Jacoco coverage reports."
reports {
xml.required.set(true)
html.required.set(true)
}
// variant.javaCompile.source does not work
// traverses from starting point
def debugTree = fileTree(dir: variant.javaCompileProvider.get().destinationDirectory, excludes: autoGenerated)
def kotlinDebugTree = fileTree(dir: "${buildDir}/tmp/kotlin-classes/${variant.name}", excludes: autoGenerated)
def variantSourceSets = variant.sourceSets.java.srcDirs.collect { it.path }.flatten()
sourceDirectories.from = [
variantSourceSets,
"src/main/java/com/kickstarter/"
]
classDirectories.from = files([debugTree], [kotlinDebugTree])
def unitTestTask = "test${variantName.capitalize()}UnitTest"
def unitTestsData = "$project.buildDir/jacoco/${unitTestTask}.exec"
executionData.from = files([unitTestsData, "${buildDir}/jacoco/test${variantName}UnitTest.exec"])
}
}