CI: [ANDROAPP-7479] update jacoco configuration#4620
Conversation
There was a problem hiding this comment.
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.ktsconfiguration 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.buildDirectoryAPI in existingjacoco.gradle.kts - Updated Jacoco version reference in
build.gradle.ktsto 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.
| // 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") |
There was a problem hiding this comment.
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.
| // 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") |
| if (isKmpProject) { | ||
| val commonTestTask = tasks.findByName("test") | ||
| val androidTestTask = tasks.findByName("androidTest") | ||
|
|
||
| if (commonTestTask != null) dependsOn(commonTestTask) | ||
| if (androidTestTask != null) dependsOn(androidTestTask) |
There was a problem hiding this comment.
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.
| // 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)) |
There was a problem hiding this comment.
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.
| // 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) |
| "**/AutoValue*.*", | ||
| "**/*\$*", | ||
| "**/*Navigator.*", | ||
| "**/*\$*\$*.*", |
There was a problem hiding this comment.
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.
| "**/*\$*\$*.*", |
| "**/BuildConfig.*", | ||
| "**/*Component*.*", | ||
| "**/*BR*.*", | ||
| "**/Manifest*.*", |
There was a problem hiding this comment.
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.
| "**/BuildConfig.*", | |
| "**/*Component*.*", | |
| "**/*BR*.*", | |
| "**/Manifest*.*", | |
| "**/*Component*.*", | |
| "**/*BR*.*", |
edb252a to
ac3ef88
Compare
There was a problem hiding this comment.
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.
| 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\$*\$*.*" | ||
| ) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| 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\$*\$*.*" | ||
| ) |
There was a problem hiding this comment.
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.
| 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\$*\$*.*" | |
| ) |
| 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()) | ||
| } |
There was a problem hiding this comment.
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.
| composeTestRule.waitUntilExactlyOneExists( | ||
| hasTestTag("TABLE_SCROLLABLE_COLUMN"), | ||
| timeoutMillis = 15000 | ||
| ) |
There was a problem hiding this comment.
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.
| 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)) |
There was a problem hiding this comment.
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.
|
|
||
| if (isKmpProject) { | ||
| // KMP project class directories | ||
| val commonClasses = fileTree(layout.buildDirectory.dir("classes/kotlin/common")){ |
There was a problem hiding this comment.
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.
| val commonClasses = fileTree(layout.buildDirectory.dir("classes/kotlin/common")){ | |
| val commonClasses = fileTree(layout.buildDirectory.dir("classes/kotlin/commonMain")){ |
| 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")){ |
There was a problem hiding this comment.
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.
| 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")){ |
4a19e6a to
f6b79ec
Compare
f6b79ec to
d1244ca
Compare
There was a problem hiding this comment.
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.
| // 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)) |
There was a problem hiding this comment.
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).
| // 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)) |
| // 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) | ||
| } | ||
|
|
There was a problem hiding this comment.
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.
| // 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) | |
| } |
d1244ca to
5a44fe4
Compare
Description
Link the JIRA issue.
update jacoco test coverage configuration