-
Notifications
You must be signed in to change notification settings - Fork 1
/
jacoco-report.gradle
71 lines (64 loc) · 2.34 KB
/
jacoco-report.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
apply plugin: 'jacoco'
/**
* The correct path of the report is $rootProjectDir/app/build/reports/jacoco/index.html
* to run this task use: ./gradlew clean jacocoTestReport
*/
jacoco{
toolVersion = "0.8.5"
}
def mainSrc = "${project.projectDir}/src/main/java"
def fileFilter = [
'**/*Activity.*',
'**/*Fragment.*',
'**/*Test*.*',
'**/AutoValue_*.*',
'**/*JavascriptBridge.class',
'**/R.class',
'**/R$*.class',
'**/Manifest*.*',
'android/**/*.*',
'**/BuildConfig.*',
'**/*$ViewBinder*.*',
'**/*$ViewInjector*.*',
'**/Lambda$*.class',
'**/Lambda.class',
'**/*Lambda.class',
'**/*Lambda*.class',
'**/*$InjectAdapter.class',
'**/*$ModuleAdapter.class',
'**/*$ViewInjector*.class',
'**/*_MembersInjector.class', //Dagger2 generated code
'*/*_MembersInjector*.*', //Dagger2 generated code
'**/*_*Factory*.*', //Dagger2 generated code
'*/*Component*.*', //Dagger2 generated code
'**/*Module*.*', //Dagger2 generated code
'**/com/openwallet/view/*',
'**/com/openwallet/di/*',
'**/com/openwallet/base/*',
'**/com/openwallet/base/adapter/*',
]
def javaDebugTree = fileTree(dir: "${buildDir}/intermediates/javac/debug/classes", excludes: fileFilter)
def kotlinDebugTree = fileTree(dir: "${buildDir}/tmp/kotlin-classes/debug", excludes: fileFilter)
task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest','createDebugCoverageReport']) {
group = "Reporting"
description = "Generate Jacoco reports after running tests"
reports {
xml.enabled = true
html.enabled = true
}
sourceDirectories.setFrom(files([mainSrc]))
classDirectories.setFrom(files([javaDebugTree, kotlinDebugTree]))
executionData.setFrom(files("$buildDir/outputs/code-coverage/connected/*coverage.ec"))
doFirst {
new File("$buildDir/intermediates/javac/debug/classes/".eachFileRecure{ file ->
if (file.name.contains('$$')){
file.renameTo(file.path.replace('$$','$'))
}
})
new File("$buildDir/tmp/kotlin-classes/debug/".eachFileRecure{ file ->
if (file.name.contains('$$')){
file.renameTo(file.path.replace('$$','$'))
}
})
}
}