-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjacoco.gradle
55 lines (50 loc) · 1.54 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
apply plugin: 'jacoco'
jacoco {
toolVersion = "0.8.11"
reportsDirectory = layout.projectDirectory.dir("reports/jacoco")
}
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 {
xml.required = true
html.required = true
}
final def coverageSourceDirs = [
"$projectDir/src/main/java"
]
final def javaDebugTree = fileTree(
dir: "$buildDir/intermediates/javac/debug/compileDebugJavaWithJavac/classes",
)
sourceDirectories.from = files(coverageSourceDirs)
classDirectories.from = files(javaDebugTree)
executionData.from = fileTree(
dir: project.layout.buildDirectory,
includes: ['jacoco/testDebugUnitTest.exec']
)
}
}