-
-
Notifications
You must be signed in to change notification settings - Fork 49
/
coverage.gradle
43 lines (38 loc) · 1.3 KB
/
coverage.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
apply plugin: 'jacoco'
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
jacoco.excludes = ['jdk.internal.*']
}
project.afterEvaluate {
def variantName = 'unbrandedDebug'
def testType = "${variantName}UnitTest"
def testTaskName = "test${testType.capitalize()}"
tasks.create(name: "make${testType.capitalize()}CoverageReport", type: JacocoReport, dependsOn: testTaskName) {
group = 'Reporting'
description = "Generate Jacoco coverage report for the ${variantName} build."
def excludes = [
'**/R.class',
'**/R$*.class',
'**/BuildConfig.*',
'**/Manifest*.*',
'**/*Test*.*',
'android/**/*.*',
'androidx/**/*.*',
'**/*_Factory.*',
'**/*_Provide*Factory*.*',
'**/*_ViewBinding*.*',
'**/AutoValue_*.*',
'**/R2.class',
'**/R2$*.class',
'**/*Directions$*',
'**/*Directions.*',
'**/*Binding.*'
]
classDirectories.from = files(fileTree(
dir: layout.buildDirectory.dir("intermediates/javac/${variantName}/compile${variantName.capitalize()}JavaWithJavac/classes"),
excludes: excludes
))
sourceDirectories.from = file("${project.projectDir}/src/main/java")
executionData.from = layout.buildDirectory.file("outputs/unit_test_code_coverage/${testType}/${testTaskName}.exec")
}
}