forked from paulin/family-bank-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjacoco.gradle
81 lines (81 loc) · 2.63 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
apply plugin: 'jacoco'
jacoco {
// You might need to change this to 0.8.5 if you see an exit value like "134"
toolVersion = "0.8.5"
}
def coverageSourceDirs = [
'src/main/java',
'src/debug/java'
]
def excludes = [
'**/R.class',
'**/R$*.class',
'**/*$ViewInjector*.*',
'**/*$ViewBinder*.*',
'**/BuildConfig.*',
'**/Manifest*.*',
'**/*RealmProxy.*',
'**/*ColumnInfo.*',
'**/*RealmModule*.*',
'**/AutoValue_*.*',
'**/Dagger*.*',
'**/*Module_Provide*Factory.*',
'**/*_Factory.*',
'**/*_MembersInjector.*',
'**/*_LifecycleAdapter.*',
'**/models/**'
]
def javaClasses = fileTree(
dir : 'build/intermediates/javac/debug/classes/com/example',
excludes : excludes
)
def kotlinClasses = fileTree(
dir : 'build/tmp/kotlin-classes/debug/com/example',
excludes : excludes
)
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
jacoco.excludes = ['jdk.internal.*']
}
task jacocoTestReport(type : JacocoReport, dependsOn : ['testDebugUnitTest']) {
group = 'Reporting'
description = 'Generate JaCoCo coverage reports'
reports {
xml.enabled = true
html.enabled = true
}
getClassDirectories().setFrom(files([javaClasses, kotlinClasses]))
getSourceDirectories().setFrom(files(coverageSourceDirs))
getExecutionData().setFrom(fileTree(
dir : "$buildDir",
include : [ 'jacoco/testDebugUnitTest.exec', 'outputs/code_coverage/debugAndroidTest/connected/*coverage.ec' ]
))
doFirst {
files([javaClasses, kotlinClasses]).getFiles().each { file ->
if (file.name.contains('$$')) {
file.renameTo(file.path.replace('$$', '$'))
}
}
}
}
task jacocoTestReportLocal(type : JacocoReport, dependsOn : ['testDebugUnitTest', 'createDebugCoverageReport']) {
group = 'Reporting'
description = 'Generate JaCoCo coverage reports'
reports {
xml.enabled = true
html.enabled = true
}
getClassDirectories().setFrom(files([javaClasses, kotlinClasses]))
getSourceDirectories().setFrom(files(coverageSourceDirs))
getExecutionData().setFrom(fileTree(
dir : "$buildDir",
include : [ 'jacoco/testDebugUnitTest.exec', 'outputs/code_coverage/debugAndroidTest/connected/*coverage.ec' ]
))
doFirst {
files([javaClasses, kotlinClasses]).getFiles().each { file ->
if (file.name.contains('$$')) {
file.renameTo(file.path.replace('$$', '$'))
}
}
}
}