smithy-rs/gradle/maincodecoverage.gradle

72 lines
2.2 KiB
Groovy

/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
allprojects {
apply plugin: "jacoco"
jacoco {
toolVersion = "0.8.5"
reportsDir = file("${buildDir}/jacoco-reports")
}
}
subprojects {
task testCoverageSubproject(type: JacocoReport) {
group = "Reporting"
description = "Generate Jacoco coverage reports."
def coverageSourceDirs = [
"common/src",
"jvm/src",
"src/main/kotlin"
]
// Do not add example projects coverage info
if (!project.name.contains("example")) {
classDirectories.from files(fileTree(dir: "${buildDir}/classes/kotlin/jvm/"), fileTree(dir: "${buildDir}/classes/kotlin/"))
sourceDirectories.from files(coverageSourceDirs)
additionalSourceDirs.from files(coverageSourceDirs)
}
// Add corresponding test.exec file according to platforms in the project
if ("codegen" == project.name) {
executionData.from files("${buildDir}/jacoco/test.exec")
} else {
executionData.from files("${buildDir}/jacoco/jvmTest.exec")
}
reports {
xml.enabled true
csv.enabled false
html.enabled true
html.destination file("${buildDir}/jacoco-reports/html")
}
}
}
task testCoverageMain(type: JacocoReport) {
group = "Reporting"
description = "Generate Jacoco coverage reports."
dependsOn subprojects.testCoverageSubproject
dependsOn "jacocoMerge"
def classes = files(subprojects.collect {
files(fileTree(dir: "${it.buildDir}/classes/kotlin/jvm").filter({file -> !file.absolutePath.contains('design/example')}))
files(fileTree(dir: "${it.buildDir}/classes/kotlin").filter({file -> !file.absolutePath.contains('design/example')}))
})
def samples = files(subprojects.testCoverageSubproject.executionData).findAll { it.exists() }
classDirectories.from files(classes)
executionData.from(samples)
reports {
xml.enabled true
csv.enabled false
html.enabled true
html.destination file("${buildDir}/jacoco-reports/html")
}
}