-
Notifications
You must be signed in to change notification settings - Fork 24
/
jacoco.gradle
37 lines (31 loc) · 1.4 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
apply plugin: "jacoco"
task jacocoReport(type: JacocoReport, dependsOn: ['test']) {
group = 'Reporting'
description = 'Generate Jacoco coverage reports after running tests.'
reports {
xml.enabled = true
html.enabled = true
}
// "gradle dependencies" - shows configurations
// "jacocoAgent/jacocoAnt" and "androidJacocoAgent/androidJacocoAnt"
// The Android version is a newer version
// Use hidden configuration, for details look into JacocoPlugin.groovy
// jacocoClasspath = configurations['androidJacocoAnt']
// exclude auto-generated classes and tests
// def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
def debugTree = fileTree(dir: "${buildDir}/classes/main")
def javaSrc = "${projectDir}/src/main/java"
def groovySrc = "${projectDir}/src/main/groovy"
sourceDirectories = files([javaSrc, groovySrc])
classDirectories = files([debugTree])
executionData = fileTree(dir: projectDir, includes: ['**/*.exec'])
// Bit hacky but fixes https://code.google.com/p/android/issues/detail?id=69174.
// We iterate through the compiled .class tree and rename $$ to $.
doFirst {
new File("$buildDir/classes/").eachFileRecurse { file ->
if (file.name.contains('$$')) {
file.renameTo(file.path.replace('$$', '$'))
}
}
}
}