-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjacoco.gradle
63 lines (58 loc) · 1.75 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
apply plugin: 'jacoco'
jacoco {
toolVersion = "0.8.7"
}
afterEvaluate { project ->
setupAndroidReporting(project)
}
ext {
getFileFilter = { ->
def jacocoSkipClasses = null
if (project.hasProperty('jacocoSkipClasses')) {
jacocoSkipClasses = project.property('jacocoSkipClasses')
}
def fileFilter = ['**/R.class', '**/R$*.class',
'**/BuildConfig.*', '**/Manifest*.*', '**/*$ViewInjector*.*']
if (jacocoSkipClasses != null) {
fileFilter.addAll(jacocoSkipClasses)
}
return fileFilter
}
}
def setupAndroidReporting(Project currentProject) {
tasks.withType(Test) {
jacoco.includeNoLocationClasses true
jacoco.excludes = ['jdk.internal.*']
}
task jacocoTestReport(
type: JacocoReport,
dependsOn: [
'testDebugUnitTest'
]) {
reports {
csv.enabled false
xml {
enabled true
xml.destination file("${buildDir}/reports/jacoco/jacoco.xml")
}
html {
enabled true
html.destination file("${buildDir}/reports/jacoco")
}
}
final def coverageSourceDirs = [
"$projectDir/src/main/java"
]
final def fileFilter = project.getFileFilter()
final def javaDebugTree = fileTree(
dir: "$buildDir/intermediates/javac/debug/classes",
excludes: fileFilter
)
sourceDirectories.from = files(coverageSourceDirs)
classDirectories.from = files([javaDebugTree])
executionData.from = fileTree(
dir: project.buildDir,
includes: ['jacoco/testDebugUnitTest.exec']
)
}
}