1
0
mirror of https://github.com/ultrasonic/ultrasonic synced 2024-12-15 10:24:18 +01:00
ultrasonic-app-subsonic-and.../gradle_scripts/jacoco.gradle
Yahor Berdnikau 1e806e3658 Added cache module to code coverage reports.
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
2018-03-11 11:56:38 +01:00

64 lines
2.3 KiB
Groovy

apply plugin: 'jacoco'
task jacocoMergeReports(type: JacocoMerge) {
group = "Reporting"
description = "Merge all jacoco reports from projects into one."
def subsonicApi = project.findProject("subsonic-api")
def ultrasonicApp = project.findProject("ultrasonic")
def cache = project.findProject("cache")
executionData(
"${subsonicApi.buildDir}/jacoco/test.exec",
"${ultrasonicApp.buildDir}/jacoco/testDebugUnitTest.exec",
"${cache.buildDir}/jacoco/test.exec"
)
destinationFile(file("${project.buildDir}/jacoco/jacoco.exec"))
}
def createJacocoFullReportTask() {
tasks.create(name: 'jacocoFullReport', type: JacocoReport, dependsOn: 'jacocoMergeReports') {
group = "Reporting"
description = "Generate full Jacoco coverage report including all modules."
def subsonicApi = project.findProject("subsonic-api")
def ultrasonicApp = project.findProject("ultrasonic")
def cache = project.findProject("cache")
classDirectories = files(
fileTree(
dir: "${subsonicApi.buildDir}/classes/main",
excludes: subsonicApi.jacocoExclude
),
fileTree(
dir: "${ultrasonicApp.buildDir}/intermediates/classes/debug/org",
excludes: ultrasonicApp.jacocoExclude
),
fileTree(
dir: "${cache.buildDir}/classes/kotlin/main",
excludes: cache.jacocoExclude
)
)
sourceDirectories = files(subsonicApi.sourceSets.main.getAllSource(),
ultrasonicApp.extensions.getByName('android').sourceSets.main.java.sourceFiles)
executionData = files("${buildDir}/jacoco/jacoco.exec")
reports {
xml.enabled = true
html.enabled = true
csv.enabled = false
}
}
}
// We need to wait to all subprojects configuration finish or we don't get sources and exclusions
def subprojectsCount = allprojects.size()
allprojects {
afterEvaluate { subproject ->
subprojectsCount--
if (subprojectsCount == 0) {
apply {
createJacocoFullReportTask()
}
}
}
}