From cb2b73c1bee59c2c3ab0400d295c70b797378724 Mon Sep 17 00:00:00 2001 From: fadidurah Date: Mon, 20 Jul 2026 02:32:02 -0400 Subject: [PATCH] Add jacocoDistTestReport task for weekly coverage XML Register a dedicated JaCoCo XML+HTML report task (jacocoDistTestReport) targeting the distDebug variant used by the weekly release pipeline, alongside the existing jacocoTestReport (localDebug) used by PR validation. This lets the weekly pipeline produce coverage XML from the dist flavor without changing any PR-facing behavior. Both tasks are registered via a shared closure so their configuration stays in sync. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- msal/build.gradle | 80 +++++++++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 34 deletions(-) diff --git a/msal/build.gradle b/msal/build.gradle index 968462450..6759d6eee 100644 --- a/msal/build.gradle +++ b/msal/build.gradle @@ -50,44 +50,56 @@ tasks.withType(Test) { } } -tasks.register("jacocoTestReport", JacocoReport) { - dependsOn "testLocalDebugUnitTest" // Run Robolectric tests first +// Registers a JaCoCo XML+HTML coverage report task for a given build variant's unit tests. +// PR validation builds the 'local' flavor, so the PR checks invoke jacocoTestReport +// (localDebug) and its behaviour is unchanged. The weekly release pipeline builds the +// 'dist' flavor and invokes jacocoDistTestReport (distDebug), which reuses the .exec +// produced by distDebugUnitTestCoverageReport rather than re-running tests on a +// variant the weekly infrastructure doesn't build. +def registerJacocoXmlReport = { String taskName, String variant -> + def variantCap = variant.capitalize() + tasks.register(taskName, JacocoReport) { + dependsOn "test${variantCap}UnitTest" // Run Robolectric tests first + + reports { + xml.required = true + html.required = true + } - reports { - xml.required = true - html.required = true + def fileFilter = [ + '**/R.class', '**/R$*.class', '**/BuildConfig.*', + '**/Manifest*.*', '**/*Test*.*', + 'android/**/*.*' + ] + + def kotlinClasses = fileTree( + dir: "$buildDir/tmp/kotlin-classes/${variant}", + excludes: fileFilter + ) + + def javaClasses = fileTree( + dir: "$buildDir/intermediates/javac/${variant}/compile${variantCap}JavaWithJavac/classes", + excludes: fileFilter + ) + + sourceDirectories.setFrom(files([ + "$projectDir/src/main/java", + "$projectDir/src/main/kotlin" + ])) + classDirectories.setFrom(files([kotlinClasses, javaClasses])) + executionData.setFrom(fileTree( + dir: buildDir, + includes: [ + "jacoco/test${variantCap}UnitTest.exec".toString(), + "outputs/unit_test_code_coverage/${variant}UnitTest/test${variantCap}UnitTest.exec".toString() + ] + )) } - - def fileFilter = [ - '**/R.class', '**/R$*.class', '**/BuildConfig.*', - '**/Manifest*.*', '**/*Test*.*', - 'android/**/*.*' - ] - - def kotlinClasses = fileTree( - dir: "$buildDir/tmp/kotlin-classes/localDebug", - excludes: fileFilter - ) - - def javaClasses = fileTree( - dir: "$buildDir/intermediates/javac/localDebug/compileLocalDebugJavaWithJavac/classes", - excludes: fileFilter - ) - - sourceDirectories.setFrom(files([ - "$projectDir/src/main/java", - "$projectDir/src/main/kotlin" - ])) - classDirectories.setFrom(files([kotlinClasses, javaClasses])) - executionData.setFrom(fileTree( - dir: buildDir, - includes: [ - "jacoco/testLocalDebugUnitTest.exec", - "outputs/unit_test_code_coverage/localDebugUnitTest/testLocalDebugUnitTest.exec" - ] - )) } +registerJacocoXmlReport("jacocoTestReport", "localDebug") // PR validation (local flavor) +registerJacocoXmlReport("jacocoDistTestReport", "distDebug") // weekly release (dist flavor) + def robolectricRepoUsername = System.getenv("ENV_VSTS_MVN_CRED_USERNAME") != null ? System.getenv("ENV_VSTS_MVN_CRED_USERNAME") : project.findProperty("vstsUsername") def robolectricRepoPassword = System.getenv("ENV_VSTS_MVN_CRED_ACCESSTOKEN") != null ? System.getenv("ENV_VSTS_MVN_CRED_ACCESSTOKEN") : project.findProperty("vstsMavenAccessToken")