-
Notifications
You must be signed in to change notification settings - Fork 137
CI: [ANDROAPP-7479] update jacoco configuration #4620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,157 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| apply(plugin = "jacoco") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Check if this is a Kotlin Multiplatform project | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| val isKmpProject = plugins.hasPlugin("org.jetbrains.kotlin.multiplatform") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| val isAndroidProject = plugins.hasPlugin("com.android.library") || plugins.hasPlugin("com.android.application") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tasks.register("jacocoReport", JacocoReport::class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| group = "Coverage" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description = "Generate XML/HTML code coverage reports" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Set source directories based on project type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (isKmpProject) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 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") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // For Android projects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sourceDirectories.setFrom("${project.projectDir}/src/main/java") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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*.*", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+40
to
+43
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "**/BuildConfig.*", | |
| "**/*Component*.*", | |
| "**/*BR*.*", | |
| "**/Manifest*.*", | |
| "**/*Component*.*", | |
| "**/*BR*.*", |
Copilot
AI
Jan 29, 2026
There was a problem hiding this comment.
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.
| "**/*\$*\$*.*", |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
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
AI
Jan 30, 2026
There was a problem hiding this comment.
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.
| 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
AI
Feb 10, 2026
There was a problem hiding this comment.
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).
| // 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
AI
Jan 30, 2026
There was a problem hiding this comment.
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.
| val commonClasses = fileTree(layout.buildDirectory.dir("classes/kotlin/common")){ | |
| val commonClasses = fileTree(layout.buildDirectory.dir("classes/kotlin/commonMain")){ |
Copilot
AI
Jan 30, 2026
There was a problem hiding this comment.
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.
| 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
AI
Jan 29, 2026
There was a problem hiding this comment.
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.
| // 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
AI
Jan 29, 2026
There was a problem hiding this comment.
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
AI
Feb 10, 2026
There was a problem hiding this comment.
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.
| // 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) | |
| } |
There was a problem hiding this comment.
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.