Hi here, i've been trying to convert Kover to a gr...
# gradle
r
Hi here, i've been trying to convert Kover to a gradle convention plugin but i can't get
KoverReportExtension
to resolve in my script. I have imported the kover gradle plugin in my
build.gradle
and can resolve
KoverReportTask
Copy code
package codequality

import kotlinx.kover.api.KoverTaskExtension

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure

class KoverPlugin : Plugin<Project> {
    override fun apply(target: Project) {
        with(target) {
            pluginManager.apply(
                "org.jetbrains.kotlinx.kover"
            )
            configureKover()
        }
    }
}

private fun Project.configureKover() {
    extensions.configure<KoverTaskExtension> {
 
    }
    
}

private fun Project.koverReport(block: KoverReportExtension.() -> Unit) {
    extensions.configure<KoverReportExtension>(block)
}
s
Hi, which version are you using?
r
I'm using the latest version 0.7.4
s
Also, in
0.7.4
version, the
KoverTaskExtension
class is deprecated. Is the code you provided the content of the precompiled convention plugin?
r
Yes it is. I'm trying to convert a gradle script to a kotlin convention plugin and that was the type i saw in the inlay hints from android studio
s
Could you look at this example, is this approach suitable for you? The
0.7.1
version was used here, but you can see how the convention plugins are used for Kover
r
why is CoverageExtension an open class in the example?
s
In Gradle, extensions should not be final classes
👍 1
n
@Rafs You need to add Kover plugin as a regular dependency to you convention plugin project
Copy code
kover-plugin = { group = "org.jetbrains.kotlinx", name = "kover-gradle-plugin", version.ref = "kover" }
In
build-logic/../build.gradle.kts
project you need to add:
Copy code
dependencies {
    compileOnly(libs.kover.plugin)
}
r
Thanks @Nick Kleban, I was missing the dependency
👍 1