This repository was archived by the owner on Dec 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathjacoco.gradle
More file actions
64 lines (58 loc) · 2.23 KB
/
jacoco.gradle
File metadata and controls
64 lines (58 loc) · 2.23 KB
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
64
/*
* Copyright (c) 2020 De Staat der Nederlanden, Ministerie van Volksgezondheid, Welzijn en Sport.
* Licensed under the EUROPEAN UNION PUBLIC LICENCE v. 1.2
*
* SPDX-License-Identifier: EUPL-1.2
*
*/
jacoco {
toolVersion = '0.8.7'
}
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
jacoco.excludes = ['jdk.internal.*']
}
project.afterEvaluate {
def variants
if (project.android.hasProperty('applicationVariants')) {
variants = android.applicationVariants }
else {
variants = android.libraryVariants
}
variants.all { variant ->
def variantName = variant.name
def testTaskName = "test${variantName.capitalize()}UnitTest"
tasks.create(name: "${testTaskName}Coverage", type: JacocoReport, dependsOn: "$testTaskName") {
group = "Reporting"
description = "Generate Jacoco coverage reports for the ${variantName.capitalize()} build."
reports {
html.required = true
xml.required = true
}
def excludes = [
'jdk.internal.*',
'**/R.class',
'**/R$*.class',
'**/BuildConfig.*',
'**/*Item*.*',
'**/*Section*.*',
'**/*Fragment*.*',
'**/*Activity*.*',
'**/EnApplication.*',
'**/Manifest*.*',
'**/*Test*.*',
'android/**/*.*'
]
def javaClasses = fileTree(dir: variant.javaCompileProvider.get().destinationDir, excludes: excludes)
def kotlinClasses = fileTree(dir: "${buildDir}/tmp/kotlin-classes/${variantName}", excludes: excludes)
classDirectories.setFrom(files([javaClasses, kotlinClasses]))
sourceDirectories.setFrom(files([
"$project.projectDir/src/main/java",
"$project.projectDir/src/${variantName}/java",
"$project.projectDir/src/main/kotlin",
"$project.projectDir/src/${variantName}/kotlin"
]))
executionData.setFrom(files("${project.buildDir}/jacoco/${testTaskName}.exec"))
}
}
}