-
Notifications
You must be signed in to change notification settings - Fork 0
/
jacoco.gradle
60 lines (53 loc) · 1.72 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
allprojects {
apply plugin: 'jacoco'
jacoco {
toolVersion testing.jacoco
}
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
}
}
FileCollection jacocoSourceDirectories(Set subprojects) {
Set srcDirs = []
subprojects.each { project ->
srcDirs.add("$project.projectDir/src/main/java")
}
return files(srcDirs)
}
FileTree jacocoClassDirectories(Set subprojects) {
List<String> excludes = [
// Android
'android/**/*.*',
'**/R.class',
'**/R$*.class',
'**/BuildConfig.*',
// Databinding
'**/databinding/*Binding.*',
'**/BR.class',
// Dependency Injection
'**/injection/**/*.*',
// Pojos, Models, Entities
'**/model/*.*',
'**/entity/*.*'
]
def classDirectories = fileTree(dir: "${buildDir}/tmp/kotlin-classes/mockDebug", exclude: excludes)
subprojects.each { project ->
classDirectories += fileTree(dir: "$project.buildDir/tmp/kotlin-classes/mockDebug", exclude: excludes)
}
return classDirectories
}
task jacocoTestReport(type: JacocoReport,
dependsOn: [":data:testMockDebugUnitTest", ":app:testMockDebugUnitTest"]) {
group = 'Reporting'
description = 'Generate JaCoCo coverage reports'
sourceDirectories = jacocoSourceDirectories(subprojects)
classDirectories = jacocoClassDirectories(subprojects)
executionData = rootProject.fileTree(dir: '.', includes: [
"**/testMockDebugUnitTest.exec", "**/*coverage.ec"
])
reports {
xml.enabled = true
html.enabled = true
html.destination file("${rootProject.buildDir}/reports/coverage")
}
}