-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjacoco.gradle
More file actions
60 lines (49 loc) · 1.9 KB
/
jacoco.gradle
File metadata and controls
60 lines (49 loc) · 1.9 KB
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
apply plugin: 'jacoco'
jacoco {
toolVersion = "$jacoco_version"
}
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
}
task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) {
group "Reporting"
description "Generate Jacoco coverage reports."
reports {
xml.enabled = true
html.enabled = true
html.destination file("${rootProject.buildDir}/coverage-report")
}
def javaClasses = []
def kotlinClasses = []
def javaSrc = []
def kotlinSrc = []
def execution = []
def fileFilter = [
'**/R.class',
'**/Manifest*.*',
'android/**/*.*',
'androidx/room/*.*', //Exclude all anonymous class from room-compiler
'**/*_Impl*.*', //DAO generated implementation by room-compiler
'**/BuildConfig.*',
'**/*Test*.*'
]
rootProject.subprojects.each { project ->
javaClasses << fileTree(dir: "$project.buildDir/intermediates/javac/debug", excludes: fileFilter)
kotlinClasses << fileTree(dir: "$project.buildDir/tmp/kotlin-classes/debug", excludes: fileFilter)
javaSrc << "$project.projectDir/src/main/java"
kotlinSrc << "$project.projectDir/src/main/kotlin"
execution << fileTree(dir: project.buildDir, includes:
[
'jacoco/testDebugUnitTest.exec',
'outputs/code_coverage/debugAndroidTest/connected/**/*.ec'
])
}
print "Setting source and class directories"
getSourceDirectories().setFrom(files([javaSrc, kotlinSrc]))
getClassDirectories().setFrom(files([javaClasses, kotlinClasses]))
print "Setting execution data from Connected tests and Junit ones"
getExecutionData().setFrom(files(execution))
doLast() {
print "file://${reports.html.destination}/index.html"
}
}