Kotlin / kotlinx-kover

Apache License 2.0
1.25k stars 46 forks source link

Kover plugin not found using convention plugin approach #580

Closed igorromcy closed 1 month ago

igorromcy commented 1 month ago

Hi once again!

I'm trying to set kover on my convention plugin, like that:

fun Project.configureKover(modules: ArrayList<String>) {
    with(pluginManager) {
        apply(KoverGradlePlugin::class.java)

        kover {
            merge { config ->
                config.allProjects {
                    it.path in modules
                }
                config.createVariant("coverage") {
                    it.addWithDependencies(*arrayOf("fastDebug", "debug"), optional = true)
                }
            }
        }
    }
}

fun Project.kover(block: KoverProjectExtension.() -> Unit) {
    extensions.getByType(KoverProjectExtension::class.java).apply {
        block()
    }
}

but when I use allProjects (which I think is the right choice for me since I want to merge all reports with that filter)

I get this error:

A problem occurred configuring project ':app'.
> Plugin with id 'org.jetbrains.kotlinx.kover' not found.

but changing to use subprojects (only for testing purposes), works fine.

any idea of what I'm doing wrong?

shanshin commented 1 month ago

Hi, Do you apply your convention plugin in only one project?

Does the error repeat if you specify

plugins {
    // ...
    id ("org.jetbrains.kotlinx.kover") version "0.8.0-Beta" apply false
    // ...
}

in the root project?

igorromcy commented 1 month ago

not, that's what I'm missing.

I'm facing a circular dependency problem right now, but I believe should be easy to solve :)