Kotlin / kotlinx-kover

Apache License 2.0
1.37k stars 53 forks source link

Error trying to generate a single report using the newest beta version (0.8.0-Beta) #570

Closed igorromcy closed 8 months ago

igorromcy commented 8 months ago

Describe the bug I'm trying to use the latest Kover version since it has some great improvements around the single report approach and I'm facing this weird error when I'm trying to add a variant. Is that something inside the library or I might be missing some kind of configuration?

Errors

Caused by: kotlinx.kover.gradle.plugin.commons.KoverCriticalException: Kover error: An error occurred while executing before Kover finalize action
Please create an issue in Kover Gradle Plugin repository: https://github.com/Kotlin/kotlinx-kover/issues
    at kotlinx.kover.gradle.plugin.appliers.FinalizeKoverKt.finalizing(FinalizeKover.kt:35)
    at kotlinx.kover.gradle.plugin.KoverGradlePlugin$apply$2.invoke(KoverGradlePlugin.kt:35)
    at kotlinx.kover.gradle.plugin.KoverGradlePlugin$apply$2.invoke(KoverGradlePlugin.kt:33)
    at
....

Caused by: org.codehaus.groovy.runtime.metaclass.MissingMethodExecutionFailed: No signature of method: kotlinx.kover.gradle.plugin.appliers.KoverMergeKt$wrap$3.addWithDependencies() is applicable for argument types: (ArrayList, Boolean) values: [[debug, fastdevDebug], false]
Possible solutions: addWithDependencies([Ljava.lang.String;, boolean)
Caused by: groovy.lang.MissingMethodException: No signature of method: kotlinx.kover.gradle.plugin.appliers.KoverMergeKt$wrap$3.addWithDependencies() is applicable for argument types: (ArrayList, Boolean) values: [[debug, fastdevDebug], false]
Possible solutions: addWithDependencies([Ljava.lang.String;, boolean)

Code I'm applying the plugin to my build.gradle file

    id("org.jetbrains.kotlinx.kover") version "0.8.0-Beta" apply true

and setting the config:

kover {
    merge {
        allProjects()
        createVariant("coverage") {
            it.addWithDependencies(["debug", "fastDebug"], false)
        }
    }
}

Environment

shanshin commented 8 months ago

Hi, try this way

kover {
    merge {
        allProjects()
        createVariant("coverage") {
            it.addWithDependencies(["debug", "fastDebug"] as String[], false)
        }
    }
}

*an String array is expected, not a list

igorromcy commented 8 months ago

looks better, but for some reason doesn't find the variant I'm looking for:

A problem occurred configuring root project 'android'.
> Could not find the provided variant 'debug' to create a custom variant 'coverage'.
  Specify an existing 'jvm' variant or Android build variant name, or delete the merge.

even passing two variants, is it searching for only one?

removing the variant block (just to see what happens) gives me the same error over many modules:

> Task :feature:feature1:kaptDebugUnitTestKotlin
warning: The following options were not recognized by any processor: '[dagger.hilt.disableModulesHaveInstallInCheck, 
dagger.fastInit, dagger.hilt.android.internal.disableAndroidSuperclassValidation, dagger.hilt.android.internal.projectType, 
dagger.hilt.internal.useAggregatingRootProcessor, dagger.validateTransitiveComponentDependencies, 
dagger.strictMultibindingValidation, dagger.hilt.disableCrossCompilationRootValidation, kapt.kotlin.generated]'
shanshin commented 8 months ago

looks better, but for some reason doesn't find the variant I'm looking for:

is Android build variant debug exists in all projects of a build including root project? If not, you should limit merged projects (e.g. by subprojects() instead of allProjects()) or add variant optionally

kover {
    merge {
        allProjects()
        createVariant("coverage") {
            it.add(["debug", "fastDebug"] as String[], true)
        }
    }
}
igorromcy commented 8 months ago

that worked, amazing!

thank you for the support!