2019-07-11 07:33:21 +08:00
|
|
|
import org.ajoberstar.grgit.Grgit
|
|
|
|
|
2020-02-22 13:50:26 +08:00
|
|
|
plugins {
|
2024-04-30 08:29:02 +08:00
|
|
|
alias(libs.plugins.codecov)
|
2020-02-22 13:50:26 +08:00
|
|
|
jacoco
|
2024-04-30 08:29:02 +08:00
|
|
|
id("buildlogic.common")
|
|
|
|
id("buildlogic.artifactory-root")
|
2020-02-22 13:50:26 +08:00
|
|
|
}
|
|
|
|
|
2021-03-09 03:10:55 +08:00
|
|
|
if (!project.hasProperty("gitCommitHash")) {
|
|
|
|
apply(plugin = "org.ajoberstar.grgit")
|
|
|
|
ext["gitCommitHash"] = try {
|
|
|
|
extensions.getByName<Grgit>("grgit").head()?.abbreviatedId
|
|
|
|
} catch (e: Exception) {
|
|
|
|
logger.warn("Error getting commit hash", e)
|
|
|
|
|
|
|
|
"no.git.id"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-22 13:50:26 +08:00
|
|
|
val totalReport = tasks.register<JacocoReport>("jacocoTotalReport") {
|
|
|
|
for (proj in subprojects) {
|
|
|
|
proj.apply(plugin = "jacoco")
|
|
|
|
proj.plugins.withId("java") {
|
|
|
|
executionData(
|
2024-01-22 06:29:02 +08:00
|
|
|
fileTree(proj.layout.buildDirectory).include("**/jacoco/*.exec")
|
2020-02-22 13:50:26 +08:00
|
|
|
)
|
2023-04-13 20:42:47 +08:00
|
|
|
sourceSets(proj.the<JavaPluginExtension>().sourceSets["main"])
|
2020-02-22 13:50:26 +08:00
|
|
|
reports {
|
2023-04-13 20:42:47 +08:00
|
|
|
xml.required.set(true)
|
2024-01-22 06:29:02 +08:00
|
|
|
xml.outputLocation.set(rootProject.layout.buildDirectory.file("reports/jacoco/report.xml"))
|
2023-04-13 20:42:47 +08:00
|
|
|
html.required.set(true)
|
2020-02-22 13:50:26 +08:00
|
|
|
}
|
|
|
|
dependsOn(proj.tasks.named("test"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
afterEvaluate {
|
|
|
|
totalReport.configure {
|
|
|
|
classDirectories.setFrom(classDirectories.files.map {
|
|
|
|
fileTree(it).apply {
|
|
|
|
exclude("**/*AutoValue_*")
|
|
|
|
exclude("**/*Registration.*")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
codecov {
|
|
|
|
reportTask.set(totalReport)
|
|
|
|
}
|