forked from kunny/RxFirebase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoverage.gradle
85 lines (73 loc) · 2.4 KB
/
coverage.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
allprojects {
apply plugin: 'jacoco'
}
subprojects {
jacoco {
reportsDir = file("${buildDir}/reports")
}
task coverageReport(type: JacocoReport) {
group = "Reporting"
description = "Generate Jacoco coverage report"
sourceDirectories = files(["${projectDir}/src/main/java"])
classDirectories = fileTree(
dir: "${buildDir}/intermediates/classes/debug",
excludes: ['**/R.class',
'**/R$*.class',
'**/BuildConfig.*',
'**/Manifest*.*',
'com/android/**/*.class'])
executionData = files("${buildDir}/jacoco/testDebugUnitTest.exec")
reports {
xml.enabled = true
html.enabled = true
}
}
afterEvaluate {
tasks.findByName('coverageReport').dependsOn('testDebugUnitTest')
}
}
jacoco {
reportsDir = file("${buildDir}/reports")
}
task mergeCoverageReports(type: JacocoReport) {
group = "Reporting"
description = "Merge Jacoco coverage reports"
def sources = []
def classDirs = files()
def executions = []
subprojects.each {
if (!it.name.contains('kotlin')) {
sources << "${it.projectDir}/src/main/java"
//noinspection GrReassignedInClosureLocalVar
classDirs += fileTree(
dir: "${it.buildDir}/intermediates/classes/debug",
excludes: ['**/R.class',
'**/R$*.class',
'**/BuildConfig.*',
'**/Manifest*.*',
'com/android/**/*.class'])
def executionFile = file("${it.buildDir}/jacoco/testDebugUnitTest.exec")
if (executionFile.exists()) {
executions << executionFile.path
}
}
}
sourceDirectories = files(sources as String[])
classDirectories = classDirs
executionData = files(executions as String[])
reports {
xml {
enabled true
destination file("${buildDir}/reports/jacoco/report.xml")
}
html {
enabled true
destination file("${buildDir}/reports/jacoco/html")
}
}
afterEvaluate {
tasks.findByName('mergeCoverageReports').dependsOn {
subprojects*.coverageReport
}
}
}