-
Notifications
You must be signed in to change notification settings - Fork 2
/
jacoco.gradle
56 lines (44 loc) · 1.82 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
apply plugin: 'jacoco'
jacoco {
toolVersion = "$jacocoVersion"
}
// Force Jacoco Version
subprojects {
configurations.all {
resolutionStrategy {
eachDependency { details ->
if ('org.jacoco' == details.requested.group) {
details.useVersion "$jacocoVersion"
}
}
}
}
}
project.afterEvaluate { project ->
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
jacoco.excludes = ['jdk.internal.*']
}
final buildType = "debug"
final variant = "$buildType"
final taskName = "jacocoTest${variant.capitalize()}UnitTestReport"
task "$taskName"(type: JacocoReport, dependsOn: "test${variant.capitalize()}UnitTest") {
reports {
csv.required = false
xml.required = true
html.required = true
}
final fileFilter = rootProject.coverageFileFilter
final androidKotlinTree = fileTree(dir: "${project.buildDir}/tmp/kotlin-classes/${variant}", excludes: fileFilter)
final kotlinTree = fileTree(dir: "${project.buildDir}/classes/kotlin/main", excludes: fileFilter)
final javacTree = fileTree(dir: "${project.buildDir}/intermediates/javac/${variant}/classes", excludes: fileFilter)
final mainSrc = "${project.projectDir}/src/main/java"
final buildTypeSrc = "${project.projectDir}/src/${buildType}/java"
sourceDirectories.setFrom files([mainSrc, buildTypeSrc])
classDirectories.setFrom files([androidKotlinTree, kotlinTree, javacTree])
executionData.setFrom fileTree(dir: project.buildDir, includes: [
"jacoco/test${variant.capitalize()}UnitTest.exec",
"outputs/unit_test_code_coverage/${variant}UnitTest/test${variant.capitalize()}UnitTest.exec"
])
}
}