mirror of
https://github.com/ultrasonic/ultrasonic
synced 2025-01-05 21:37:06 +01:00
501015c649
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
75 lines
2.8 KiB
Groovy
75 lines
2.8 KiB
Groovy
apply plugin: 'jacoco'
|
|
|
|
jacoco {
|
|
toolVersion(versions.jacoco)
|
|
}
|
|
|
|
task jacocoMergeReports(type: JacocoMerge) {
|
|
group = "Reporting"
|
|
description = "Merge all jacoco reports from projects into one."
|
|
|
|
List<File> jacocoFiles = new ArrayList<>()
|
|
project.subprojects { subproject ->
|
|
File commonModuleReport = new File(subproject.buildDir, "/jacoco/test.exec")
|
|
if (commonModuleReport.exists()) jacocoFiles.add(commonModuleReport)
|
|
File androidModuleReport = new File(subproject.buildDir, "/jacoco/testDebugUnitTest.exec")
|
|
if (androidModuleReport.exists()) jacocoFiles.add(androidModuleReport)
|
|
}
|
|
executionData(jacocoFiles.toArray())
|
|
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."
|
|
|
|
List<FileTree> classFileTreeList = new ArrayList<>()
|
|
List<FileTree> sourceFileTreeList = new ArrayList<>()
|
|
project.subprojects { subproject ->
|
|
if (subproject.plugins.hasPlugin("kotlin-android") &&
|
|
subproject.hasProperty("jacocoExclude")) {
|
|
classFileTreeList.add(
|
|
fileTree(
|
|
dir: "${subproject.buildDir}/tmp/kotlin-classes/debug",
|
|
excludes: subproject.jacocoExclude
|
|
)
|
|
)
|
|
sourceFileTreeList.add(
|
|
subproject.extensions.getByName('android').sourceSets.main.java.sourceFiles
|
|
)
|
|
} else if (subproject.hasProperty("jacocoExclude")) {
|
|
classFileTreeList.add(
|
|
fileTree(
|
|
dir: "${subproject.buildDir}/classes/kotlin/main",
|
|
excludes: subproject.jacocoExclude
|
|
)
|
|
)
|
|
sourceFileTreeList.add(subproject.sourceSets.main.getAllSource())
|
|
}
|
|
}
|
|
|
|
classDirectories = files(classFileTreeList.toArray())
|
|
sourceDirectories = files(sourceFileTreeList.toArray())
|
|
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()
|
|
}
|
|
}
|
|
}
|
|
} |