Skip to content

CI: [ANDROAPP-7479] update jacoco configuration#4620

Open
andresmr wants to merge 2 commits into
developfrom
ANDROAPP-7479-update-code-coverage
Open

CI: [ANDROAPP-7479] update jacoco configuration#4620
andresmr wants to merge 2 commits into
developfrom
ANDROAPP-7479-update-code-coverage

Conversation

@andresmr
Copy link
Copy Markdown
Collaborator

Description

Link the JIRA issue.

update jacoco test coverage configuration

Copilot AI review requested due to automatic review settings January 29, 2026 13:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Jacoco test coverage configuration for the project. It introduces a new Kotlin Multiplatform (KMP) specific Jacoco configuration file and updates the existing Android-only configuration to use modern Gradle APIs. The PR also upgrades the Jacoco version from 0.8.10 to 0.8.14.

Changes:

  • Created new jacoco-kmp.gradle.kts configuration file to support both KMP and Android library modules
  • Applied the new KMP Jacoco configuration to KMP modules (tracker, sync, login, commonskmm, aggregates)
  • Modernized build directory path references using layout.buildDirectory API in existing jacoco.gradle.kts
  • Updated Jacoco version reference in build.gradle.kts to use version catalog
  • Added verification metadata for Jacoco 0.8.14 artifacts

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
jacoco/jacoco-kmp.gradle.kts New configuration file supporting Jacoco coverage for both KMP and Android projects with conditional logic for project type detection
jacoco/jacoco.gradle.kts Modernized to use layout.buildDirectory API, added test task dependencies, removed commented code
tracker/build.gradle.kts Applied new KMP Jacoco configuration
sync/build.gradle.kts Applied new KMP Jacoco configuration
login/build.gradle.kts Applied new KMP Jacoco configuration
commonskmm/build.gradle.kts Applied new KMP Jacoco configuration
aggregates/build.gradle.kts Applied new KMP Jacoco configuration
build.gradle.kts Updated to use Jacoco version from version catalog
gradle/verification-metadata.xml Added verification metadata for Jacoco 0.8.14 dependencies

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +13 to +18
// For KMP projects, include all source sets
sourceDirectories.setFrom(
layout.projectDirectory.dir("src/commonMain/kotlin"),
layout.projectDirectory.dir("src/androidMain/kotlin"),
layout.projectDirectory.dir("src/commonTest/kotlin"),
layout.projectDirectory.dir("src/androidUnitTest/kotlin")
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sourceDirectories configuration includes test source directories (src/commonTest/kotlin and src/androidUnitTest/kotlin). Source directories should only contain production code, not test code. Test directories should be excluded from code coverage source directories to ensure accurate coverage reporting. Remove lines 17-18 that include test directories.

Suggested change
// For KMP projects, include all source sets
sourceDirectories.setFrom(
layout.projectDirectory.dir("src/commonMain/kotlin"),
layout.projectDirectory.dir("src/androidMain/kotlin"),
layout.projectDirectory.dir("src/commonTest/kotlin"),
layout.projectDirectory.dir("src/androidUnitTest/kotlin")
// For KMP projects, include only production source sets
sourceDirectories.setFrom(
layout.projectDirectory.dir("src/commonMain/kotlin"),
layout.projectDirectory.dir("src/androidMain/kotlin")

Copilot uses AI. Check for mistakes.
Comment on lines +138 to +143
if (isKmpProject) {
val commonTestTask = tasks.findByName("test")
val androidTestTask = tasks.findByName("androidTest")

if (commonTestTask != null) dependsOn(commonTestTask)
if (androidTestTask != null) dependsOn(androidTestTask)
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test task name "test" used here may not exist for Kotlin Multiplatform projects. KMP projects typically have platform-specific test tasks like "allTests", "testDebugUnitTest", "jvmTest", "desktopTest", etc. Consider using more specific task names or making this conditional based on the actual available test tasks. The same applies to "androidTest" on line 140 which is typically named "testDebugUnitTest" or "testReleaseUnitTest" for Android unit tests.

Copilot uses AI. Check for mistakes.
Comment on lines +103 to +114
// KMP project class directories
val commonClasses = fileTree(layout.buildDirectory.dir("classes/kotlin/common")){
exclude(excludes)
}
val androidClasses = fileTree(layout.buildDirectory.dir("classes/kotlin/android")){
exclude(excludes)
}
val jvmClasses = fileTree(layout.buildDirectory.dir("classes/kotlin/jvm")){
exclude(excludes)
}

classDirectoriesList.addAll(listOf(commonClasses, androidClasses, jvmClasses))
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class directory paths for KMP projects may not be accurate. Kotlin Multiplatform projects typically output compiled classes to paths like "classes/kotlin/jvm/main", "classes/kotlin/android/debug", etc., not just "classes/kotlin/common" or "classes/kotlin/android". The actual paths depend on the target configuration. Consider verifying these paths match the actual KMP build output structure or making them more flexible to handle different KMP target configurations.

Suggested change
// KMP project class directories
val commonClasses = fileTree(layout.buildDirectory.dir("classes/kotlin/common")){
exclude(excludes)
}
val androidClasses = fileTree(layout.buildDirectory.dir("classes/kotlin/android")){
exclude(excludes)
}
val jvmClasses = fileTree(layout.buildDirectory.dir("classes/kotlin/jvm")){
exclude(excludes)
}
classDirectoriesList.addAll(listOf(commonClasses, androidClasses, jvmClasses))
// KMP project class directories - include all KMP targets/variants under classes/kotlin
val kmpClasses = fileTree(layout.buildDirectory) {
include(
"classes/kotlin/**/main/**",
"classes/kotlin/**/debug/**",
"classes/kotlin/**/release/**"
)
exclude(excludes)
}
classDirectoriesList.add(kmpClasses)

Copilot uses AI. Check for mistakes.
"**/AutoValue*.*",
"**/*\$*",
"**/*Navigator.*",
"**/*\$*\$*.*",
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The duplicate pattern "/$$." on line 71 is redundant as it's already covered by the more general pattern "/$" on line 69. The more general pattern will match any file with a dollar sign in its name, which includes files with multiple dollar signs. Consider removing the duplicate pattern on line 71.

Suggested change
"**/*\$*\$*.*",

Copilot uses AI. Check for mistakes.
Comment on lines +40 to +43
"**/BuildConfig.*",
"**/*Component*.*",
"**/*BR*.*",
"**/Manifest*.*",
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exclusion pattern "/BuildConfig.*" is duplicated on lines 33 and 40, and "/Manifest*.*" is duplicated on lines 34 and 43. These duplicates should be removed to keep the exclusion list clean and maintainable.

Suggested change
"**/BuildConfig.*",
"**/*Component*.*",
"**/*BR*.*",
"**/Manifest*.*",
"**/*Component*.*",
"**/*BR*.*",

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings January 30, 2026 09:46
@andresmr andresmr force-pushed the ANDROAPP-7479-update-code-coverage branch from edb252a to ac3ef88 Compare January 30, 2026 09:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +25 to +79
val excludes = mutableSetOf<String>(
"android/databinding/**/*.class",
"**/android/databinding/*Binding.class",
"**/android/databinding/*",
"**/androidx/databinding/*",
"**/BR.*",
"**/R.class",
"**/R\$*.class",
"**/BuildConfig.*",
"**/Manifest*.*",
"**/*Test*.*",
"android/**/*.*",
"**/*MapperImpl*.*",
"**/*\$ViewInjector*.*",
"**/*\$ViewBinder*.*",
"**/BuildConfig.*",
"**/*Component*.*",
"**/*BR*.*",
"**/Manifest*.*",
"**/*\$Lambda\$*.*",
"**/*Companion*.*",
"**/*Module*.*",
"**/*Dagger*.*",
"**/*MembersInjector*.*",
"**/*_MembersInjector.class",
"**/*_Factory*.*",
"**/*_Provide*Factory*.*",
"**/*Extensions*.*",
"**/*\$Result.*",
"**/*\$Result\$*.*",
"**/*JsonAdapter.*",
"**/databinding/*.*",
"**/customviews/*.*",
"**/ui/*.class",
"**/*Activity.*",
"**/Activity*.*",
"**/*Activity*.*",
"**/*Fragment.*",
"**/Fragment*.*",
"**/*View.*",
"**/*Adapter.*",
"**/*Contract*.*",
"**/*Bindings*.*",
"**/AutoValue*.*",
"**/*\$*",
"**/*Navigator.*",
"**/*\$*\$*.*",
"**/animations/*.*",
"**/*Holder*.*",
"**/*Dialog*.*",
"**/*Service*.*",
"**/*Button*.*",
"**/SearchTEList.*",
"**/lambda\$*\$*.*"
)
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The excludes list contains duplicate entries. Line 33 and 40 both have "/BuildConfig.", and lines 34 and 43 both have "/Manifest.*". Consider removing these duplicates to keep the configuration clean and maintainable.

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings January 30, 2026 13:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +25 to +79
val excludes = mutableSetOf<String>(
"android/databinding/**/*.class",
"**/android/databinding/*Binding.class",
"**/android/databinding/*",
"**/androidx/databinding/*",
"**/BR.*",
"**/R.class",
"**/R\$*.class",
"**/BuildConfig.*",
"**/Manifest*.*",
"**/*Test*.*",
"android/**/*.*",
"**/*MapperImpl*.*",
"**/*\$ViewInjector*.*",
"**/*\$ViewBinder*.*",
"**/BuildConfig.*",
"**/*Component*.*",
"**/*BR*.*",
"**/Manifest*.*",
"**/*\$Lambda\$*.*",
"**/*Companion*.*",
"**/*Module*.*",
"**/*Dagger*.*",
"**/*MembersInjector*.*",
"**/*_MembersInjector.class",
"**/*_Factory*.*",
"**/*_Provide*Factory*.*",
"**/*Extensions*.*",
"**/*\$Result.*",
"**/*\$Result\$*.*",
"**/*JsonAdapter.*",
"**/databinding/*.*",
"**/customviews/*.*",
"**/ui/*.class",
"**/*Activity.*",
"**/Activity*.*",
"**/*Activity*.*",
"**/*Fragment.*",
"**/Fragment*.*",
"**/*View.*",
"**/*Adapter.*",
"**/*Contract*.*",
"**/*Bindings*.*",
"**/AutoValue*.*",
"**/*\$*",
"**/*Navigator.*",
"**/*\$*\$*.*",
"**/animations/*.*",
"**/*Holder*.*",
"**/*Dialog*.*",
"**/*Service*.*",
"**/*Button*.*",
"**/SearchTEList.*",
"**/lambda\$*\$*.*"
)
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exclusions list contains duplicate entries. Lines 33 and 40 both have "/BuildConfig.*", and lines 34 and 43 both have "/Manifest*.*". Remove the duplicate entries to keep the configuration clean.

Suggested change
val excludes = mutableSetOf<String>(
"android/databinding/**/*.class",
"**/android/databinding/*Binding.class",
"**/android/databinding/*",
"**/androidx/databinding/*",
"**/BR.*",
"**/R.class",
"**/R\$*.class",
"**/BuildConfig.*",
"**/Manifest*.*",
"**/*Test*.*",
"android/**/*.*",
"**/*MapperImpl*.*",
"**/*\$ViewInjector*.*",
"**/*\$ViewBinder*.*",
"**/BuildConfig.*",
"**/*Component*.*",
"**/*BR*.*",
"**/Manifest*.*",
"**/*\$Lambda\$*.*",
"**/*Companion*.*",
"**/*Module*.*",
"**/*Dagger*.*",
"**/*MembersInjector*.*",
"**/*_MembersInjector.class",
"**/*_Factory*.*",
"**/*_Provide*Factory*.*",
"**/*Extensions*.*",
"**/*\$Result.*",
"**/*\$Result\$*.*",
"**/*JsonAdapter.*",
"**/databinding/*.*",
"**/customviews/*.*",
"**/ui/*.class",
"**/*Activity.*",
"**/Activity*.*",
"**/*Activity*.*",
"**/*Fragment.*",
"**/Fragment*.*",
"**/*View.*",
"**/*Adapter.*",
"**/*Contract*.*",
"**/*Bindings*.*",
"**/AutoValue*.*",
"**/*\$*",
"**/*Navigator.*",
"**/*\$*\$*.*",
"**/animations/*.*",
"**/*Holder*.*",
"**/*Dialog*.*",
"**/*Service*.*",
"**/*Button*.*",
"**/SearchTEList.*",
"**/lambda\$*\$*.*"
)
val excludes = mutableSetOf<String>(
"android/databinding/**/*.class",
"**/android/databinding/*Binding.class",
"**/android/databinding/*",
"**/androidx/databinding/*",
"**/BR.*",
"**/R.class",
"**/R\$*.class",
"**/BuildConfig.*",
"**/Manifest*.*",
"**/*Test*.*",
"android/**/*.*",
"**/*MapperImpl*.*",
"**/*\$ViewInjector*.*",
"**/*\$ViewBinder*.*",
"**/*Component*.*",
"**/*BR*.*",
"**/*\$Lambda\$*.*",
"**/*Companion*.*",
"**/*Module*.*",
"**/*Dagger*.*",
"**/*MembersInjector*.*",
"**/*_MembersInjector.class",
"**/*_Factory*.*",
"**/*_Provide*Factory*.*",
"**/*Extensions*.*",
"**/*\$Result.*",
"**/*\$Result\$*.*",
"**/*JsonAdapter.*",
"**/databinding/*.*",
"**/customviews/*.*",
"**/ui/*.class",
"**/*Activity.*",
"**/Activity*.*",
"**/*Activity*.*",
"**/*Fragment.*",
"**/Fragment*.*",
"**/*View.*",
"**/*Adapter.*",
"**/*Contract*.*",
"**/*Bindings*.*",
"**/AutoValue*.*",
"**/*\$*",
"**/*Navigator.*",
"**/*\$*\$*.*",
"**/animations/*.*",
"**/*Holder*.*",
"**/*Dialog*.*",
"**/*Service*.*",
"**/*Button*.*",
"**/SearchTEList.*",
"**/lambda\$*\$*.*"
)

Copilot uses AI. Check for mistakes.
Comment on lines 53 to 61
fun clickYesOnAlertDialog() {
waitForView(withText(R.string.yes))
onView(isRoot())
.inRoot(isDialog())
.perform(searchFor(withId(android.R.id.button1)))
onView(withId(android.R.id.button1))
.inRoot(isDialog())
.check(matches(isDisplayed()))
.perform(click())
}
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change appears to be a test stability fix (improving dialog interaction) that is unrelated to the JaCoCo configuration update described in the PR. Consider separating test stability fixes into a different PR to keep changes focused and easier to review.

Copilot uses AI. Check for mistakes.
Comment on lines +349 to +352
composeTestRule.waitUntilExactlyOneExists(
hasTestTag("TABLE_SCROLLABLE_COLUMN"),
timeoutMillis = 15000
)
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change appears to be a test stability fix (adding explicit wait conditions) that is unrelated to the JaCoCo configuration update described in the PR. Consider separating test stability fixes into a different PR to keep changes focused and easier to review.

Copilot uses AI. Check for mistakes.
Comment on lines +110 to +126
val defaultFailureHandler = DefaultFailureHandler(getInstrumentation().targetContext)
val failureHandler = FailureHandler { error, matcher ->
if (error is NoMatchingViewException) {
throw error
}
defaultFailureHandler.handle(error, matcher)
}

for (i in 0..maxTries)
try {
// Track the amount of times we've tried
tries++

// Search the root for the view
onView(isRoot()).perform(searchFor(viewMatcher))
onView(isRoot())
.withFailureHandler(failureHandler)
.perform(searchFor(viewMatcher))
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change appears to be a test stability fix (improving error handling in waitForView) that is unrelated to the JaCoCo configuration update described in the PR. Consider separating test stability fixes into a different PR to keep changes focused and easier to review.

Copilot uses AI. Check for mistakes.

if (isKmpProject) {
// KMP project class directories
val commonClasses = fileTree(layout.buildDirectory.dir("classes/kotlin/common")){
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class directory path "classes/kotlin/common" might be incorrect for KMP projects. Kotlin Multiplatform typically uses paths like "classes/kotlin/commonMain" for common source set compilation. Verify this path matches the actual build output directory structure, or consider using "classes/kotlin/commonMain" instead.

Suggested change
val commonClasses = fileTree(layout.buildDirectory.dir("classes/kotlin/common")){
val commonClasses = fileTree(layout.buildDirectory.dir("classes/kotlin/commonMain")){

Copilot uses AI. Check for mistakes.
Comment on lines +104 to +110
val commonClasses = fileTree(layout.buildDirectory.dir("classes/kotlin/common")){
exclude(excludes)
}
val androidClasses = fileTree(layout.buildDirectory.dir("classes/kotlin/android")){
exclude(excludes)
}
val jvmClasses = fileTree(layout.buildDirectory.dir("classes/kotlin/jvm")){
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class directory paths "classes/kotlin/android" and "classes/kotlin/jvm" might be incorrect for KMP projects. Kotlin Multiplatform typically uses paths like "classes/kotlin/android/main" and "classes/kotlin/jvm/main" for target-specific compilation. Verify these paths match the actual build output directory structure.

Suggested change
val commonClasses = fileTree(layout.buildDirectory.dir("classes/kotlin/common")){
exclude(excludes)
}
val androidClasses = fileTree(layout.buildDirectory.dir("classes/kotlin/android")){
exclude(excludes)
}
val jvmClasses = fileTree(layout.buildDirectory.dir("classes/kotlin/jvm")){
val commonClasses = fileTree(layout.buildDirectory.dir("classes/kotlin/common/main")){
exclude(excludes)
}
val androidClasses = fileTree(layout.buildDirectory.dir("classes/kotlin/android/main")){
exclude(excludes)
}
val jvmClasses = fileTree(layout.buildDirectory.dir("classes/kotlin/jvm/main")){

Copilot uses AI. Check for mistakes.
@andresmr andresmr changed the title ci: update jacoco configuration CI: [ANDROAPP-7479] update jacoco configuration Feb 9, 2026
@andresmr andresmr force-pushed the ANDROAPP-7479-update-code-coverage branch from 4a19e6a to f6b79ec Compare February 9, 2026 06:02
Copilot AI review requested due to automatic review settings February 10, 2026 05:56
@andresmr andresmr force-pushed the ANDROAPP-7479-update-code-coverage branch from f6b79ec to d1244ca Compare February 10, 2026 05:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +85 to +99
// Android project class directories
val javaClassesApp = fileTree(layout.buildDirectory.dir("intermediates/javac/dhisDebug")){
exclude(excludes)
}
val kotlinClassesApp = fileTree(layout.buildDirectory.dir("tmp/kotlin-classes/dhisDebug")){
exclude(excludes)
}
val javaClasses = fileTree(layout.buildDirectory.dir("intermediates/javac/debug")){
exclude(excludes)
}
val kotlinClasses = fileTree(layout.buildDirectory.dir("tmp/kotlin-classes/debug")){
exclude(excludes)
}

classDirectoriesList.addAll(listOf(javaClassesApp, kotlinClassesApp, javaClasses, kotlinClasses))
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Android classDirectories are hard-coded to dhisDebug and debug. Modules like login define product flavors, so their debug variants will be like <flavor>Debug (e.g., dhis2Debug) and won’t be picked up by either of these paths, resulting in missing coverage. Consider collecting variant-specific class dirs dynamically (e.g., via Android Components/Variants API or by globbing over intermediates/javac/*Debug and tmp/kotlin-classes/*Debug).

Suggested change
// Android project class directories
val javaClassesApp = fileTree(layout.buildDirectory.dir("intermediates/javac/dhisDebug")){
exclude(excludes)
}
val kotlinClassesApp = fileTree(layout.buildDirectory.dir("tmp/kotlin-classes/dhisDebug")){
exclude(excludes)
}
val javaClasses = fileTree(layout.buildDirectory.dir("intermediates/javac/debug")){
exclude(excludes)
}
val kotlinClasses = fileTree(layout.buildDirectory.dir("tmp/kotlin-classes/debug")){
exclude(excludes)
}
classDirectoriesList.addAll(listOf(javaClassesApp, kotlinClassesApp, javaClasses, kotlinClasses))
// Android project class directories - include all *Debug variants
val javaDebugClasses = fileTree(layout.buildDirectory) {
// e.g. intermediates/javac/dhisDebug/classes/**, intermediates/javac/dhis2Debug/classes/**, etc.
include("intermediates/javac/*Debug/classes/**")
exclude(excludes)
}
val kotlinDebugClasses = fileTree(layout.buildDirectory) {
// e.g. tmp/kotlin-classes/dhisDebug/**, tmp/kotlin-classes/dhis2Debug/**, etc.
include("tmp/kotlin-classes/*Debug/**")
exclude(excludes)
}
classDirectoriesList.addAll(listOf(javaDebugClasses, kotlinDebugClasses))

Copilot uses AI. Check for mistakes.
Comment on lines +129 to +145
// Add test task dependencies based on project type
if (isAndroidProject) {
val testTask = tasks.findByName("testDebugUnitTest")
val androidTestTask = tasks.findByName("connectedDebugAndroidTest")

if (testTask != null) dependsOn(testTask)
if (androidTestTask != null) dependsOn(androidTestTask)
}

if (isKmpProject) {
val commonTestTask = tasks.findByName("testDebugUnitTest") ?: tasks.findByName("test")
val androidTestTask = tasks.findByName("connectedDebugAndroidTest") ?: tasks.findByName("androidTest")

if (commonTestTask != null) dependsOn(commonTestTask)
if (androidTestTask != null) dependsOn(androidTestTask)
}

Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For KMP Android library modules both isAndroidProject and isKmpProject are true, so the same Android test tasks can be added to dependsOn twice (once in each block). This is harmless but makes the task configuration harder to reason about; consider collapsing the dependency wiring into a single block that deduplicates tasks.

Suggested change
// Add test task dependencies based on project type
if (isAndroidProject) {
val testTask = tasks.findByName("testDebugUnitTest")
val androidTestTask = tasks.findByName("connectedDebugAndroidTest")
if (testTask != null) dependsOn(testTask)
if (androidTestTask != null) dependsOn(androidTestTask)
}
if (isKmpProject) {
val commonTestTask = tasks.findByName("testDebugUnitTest") ?: tasks.findByName("test")
val androidTestTask = tasks.findByName("connectedDebugAndroidTest") ?: tasks.findByName("androidTest")
if (commonTestTask != null) dependsOn(commonTestTask)
if (androidTestTask != null) dependsOn(androidTestTask)
}
// Add test task dependencies based on project type, deduplicating tasks
val testTaskNames = mutableSetOf<String>()
if (isAndroidProject) {
// Standard Android unit and instrumentation test tasks
testTaskNames.add("testDebugUnitTest")
testTaskNames.add("connectedDebugAndroidTest")
}
if (isKmpProject) {
// KMP projects may use the same Android tasks or fall back to generic ones
val commonTestName = if (tasks.findByName("testDebugUnitTest") != null) {
"testDebugUnitTest"
} else {
"test"
}
val androidTestName = if (tasks.findByName("connectedDebugAndroidTest") != null) {
"connectedDebugAndroidTest"
} else {
"androidTest"
}
testTaskNames.add(commonTestName)
testTaskNames.add(androidTestName)
}
testTaskNames.forEach { taskName ->
val task = tasks.findByName(taskName)
if (task != null) dependsOn(task)
}

Copilot uses AI. Check for mistakes.
@andresmr andresmr force-pushed the ANDROAPP-7479-update-code-coverage branch from d1244ca to 5a44fe4 Compare March 19, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants