forked from NightscoutFoundation/xDrip
-
Notifications
You must be signed in to change notification settings - Fork 3
/
jacoco.gradle
53 lines (46 loc) · 2.06 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
apply plugin: 'jacoco'
jacoco {
// This version should be same as the one defined in root project build.gradle file :
toolVersion = "0.8.7"
}
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
jacoco.excludes = ['jdk.internal.*']
}
project.afterEvaluate {
android.applicationVariants.all { variant ->
def testTaskName = "test${variant.name.capitalize()}UnitTest"
task "${testTaskName}Coverage"(type: JacocoReport, dependsOn: "$testTaskName") {
group = "Reporting"
description = "Generate Jacoco coverage reports on the ${variant.name.capitalize()} build."
def excludes = [
'**/R.class',
'**/R$*.class',
'**/*$ViewInjector*.*',
'**/*$ViewBinder*.*',
'**/BuildConfig.*',
'**/Manifest*.*'
]
//Tree for all the Java classes
def javaClasses = fileTree(dir: variant.javaCompiler.destinationDir, excludes: excludes)
//Tree for all the Kotlin classes
def kotlinClasses = fileTree(dir: "${buildDir}/tmp/kotlin-classes/${variant.name}", excludes: excludes)
//combined source directories
classDirectories.from = files([javaClasses, kotlinClasses])
def coverageSourceDirs = [
"$project.projectDir/src/main/java",
"$project.projectDir/src/${variant.name}/java",
"$project.projectDir/src/main/kotlin",
"$project.projectDir/src/${variant.name}/kotlin"
]
additionalSourceDirs.from = files(coverageSourceDirs)
sourceDirectories.from = files(coverageSourceDirs)
executionData.from = files("${project.buildDir}/jacoco/${testTaskName}.exec")
reports {
xml.enabled = true
html.enabled = project.getProperties().getOrDefault('covHtml', false) == 'true'
html.destination = file("${project.buildDir}/jacoco/")
}
}
}
}