nuhkoca
06/25/2022, 1:39 PMjacocoTestReport task that depends on testDebugUnitTest and it was just generating debug related reports and exec files but since the last week jacocoTestReport both executes debug, internal and release tasks and generates reports. This has drastically increased CI time. I never touched configuration or so. What could be the root cause to this misconduct?nuhkoca
06/25/2022, 1:40 PMnuhkoca
06/25/2022, 1:48 PMjacoco.gradle
apply plugin: 'jacoco'
tasks.withType(Test) {
jacoco.includeNoLocationClasses true
// see related issue <https://github.com/gradle/gradle/issues/5184#issuecomment-457865951>
jacoco.excludes = ['jdk.internal.*']
}
afterEvaluate { project ->
if (isModuleExcluded(project)) {
println "Jacoco: Ignoring $name module for coverage"
return false
}
if (isAndroidModule(project)) setupAndroidReporting()
else setupKotlinReporting()
}
private def setupKotlinReporting() {
jacocoTestReport {
dependsOn test
reports {
html.required.set(true)
xml.required.set(true)
}
}
}
private def setupAndroidReporting() {
task jacocoTestReport(type: JacocoReport, dependsOn: 'testDebugUnitTest') {
group = "Reporting"
description = "Generate Jacoco coverage reports for the debug build"
reports {
html.required.set(true)
xml.required.set(true)
}
def javaTree = fileTree(
dir: "$buildDir/intermediates/javac/debug",
excludes: coverageExcludes
)
def kotlinTree = fileTree(
dir: "$buildDir/tmp/kotlin-classes/debug",
excludes: coverageExcludes
)
classDirectories.setFrom(files([javaTree, kotlinTree]))
def coverageSourceDirs = [
"$projectDir/src/main/java",
"$projectDir/src/main/kotlin"
]
sourceDirectories.setFrom(files(coverageSourceDirs))
executionData.setFrom(files("$buildDir/jacoco/testDebugUnitTest.exec"))
}
}nuhkoca
06/25/2022, 1:48 PMcoverage.gradle
apply from: "buildsystem/quality/coverage/coverage-config.gradle"
apply from: "buildsystem/quality/coverage/sonar.gradle"
apply plugin: 'jacoco'
subprojects { project ->
project.apply from: "../buildsystem/quality/coverage/jacoco.gradle"
}
def jacocoFullReport = tasks.register("jacocoFullReport", JacocoReport) {
group = 'Reporting'
description = 'Generates an aggregated report from all subprojects'
def projects = subprojects.findAll { project -> !isModuleExcluded(project) }
dependsOn(projects.jacocoTestReport)
final source = files(projects.jacocoTestReport.sourceDirectories)
additionalSourceDirs.setFrom(source)
sourceDirectories.setFrom(source)
classDirectories.setFrom(files(projects.jacocoTestReport.classDirectories))
executionData.setFrom(files(projects.jacocoTestReport.executionData))
reports {
html.required.set(true)
html.outputLocation.set(file("$buildDir/reports/jacoco/html"))
xml.required.set(true)
xml.outputLocation.set(file("$buildDir/reports/jacoco/jacocoFullReport.xml"))
}
}
tasks.sonarqube.dependsOn jacocoFullReportnuhkoca
06/25/2022, 3:22 PMjacocoTestReport task created by me but now there are 3 others created by something else 🤔 Has something changed with Gradle’s latest version?nuhkoca
06/26/2022, 10:47 AM