-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjacoco.gradle
47 lines (37 loc) · 1.33 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
apply plugin: 'jacoco'
ext {
coverageExclusions = [
'**/*Activity*.*',
'**/*Fragment*.*',
'**/R.class',
'**/R$*.class',
'**/BuildConfig.*',
]
}
jacoco {
toolVersion = "0.8.9"
reportsDirectory = layout.buildDirectory.dir("$buildDir/reports")
}
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
// https://github.com/gradle/gradle/issues/5184#issuecomment-457865951
jacoco.excludes = ['jdk.internal.*']
}
tasks.withType(Test) {
finalizedBy jacocoTestReport // report is always generated after tests run
}
task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest']) {
group = "Reporting"
description = "Generate Jacoco coverage reports for Debug build"
reports {
xml.required.set(true)
csv.required.set(false)
}
def javaTree = fileTree(dir: "$project.buildDir/intermediates/javac/debug/classes", excludes: coverageExclusions)
def kotlinTree = fileTree(dir: "$project.buildDir/tmp/kotlin-classes/debug", excludes: coverageExclusions)
def mainSrc = "/src/main/java"
additionalSourceDirs.from = files(mainSrc)
sourceDirectories.from = files([mainSrc])
classDirectories.from = files([javaTree, kotlinTree])
executionData.from = files("${buildDir}/jacoco/testDebugUnitTest.exec")
}