Hello I am trying to convert a Gradle module (JVM ...
# multiplatform
e
Hello I am trying to convert a Gradle module (JVM library) into a multiplatform module (JVM+JS) in an Android app project. However, I found that there is build fail after I convert the setup into Gradle convention plugins. I have tried to modify the module's build.gradle.kts first without applying any custom Gradle convention plugins and it works. Then I copy the setup in the module's build.gradle.kts into Gradle convention plugins but found out these issues: It looks like inside convention plugin, it does not have things like
kspJvm
, only have
ksp
Copy code
dependencies {
    add("kspJvm", libs.findLibrary("dagger.hilt.compiler").get())
}
It just say build fail and does not have configuration of
kspJvm
. However, it works before moving the code into convention plugin:
Copy code
dependencies {
    add("kspJvm", libs.dagger.hilt.compiler)
    add("jvmTestImplementation", platform(libs.junit.bom))
    add("jvmTestRuntimeOnly", platform(libs.junit.bom))
}
Some dependencies cannot be resolved Before moving the code into convention plugin:
Copy code
kotlin {
    sourceSets {
        jvmTest.dependencies {
            compileOnly(libs.junit4)
            runtimeOnly(libs.junit.jupiter.engine)
            implementation(libs.junit.jupiter)
            implementation(libs.junit.jupiter.api)
            implementation(libs.junit.jupiter.params)
            runtimeOnly(libs.junit.vintage.engine)

            implementation(libs.kotest.runnerJunit5)

            implementation(libs.mockk)
        }
    }
}
After moving into convention plugin:
Copy code
extensions.configure<KotlinMultiplatformExtension> {
    with(sourceSets) {
                    jvmTest.dependencies {
                        compileOnly(libs.findLibrary("junit4").get())
                        runtimeOnly(libs.findLibrary("junit.jupiter.engine").get())
                        implementation(libs.findLibrary("junit.jupiter").get())
                        implementation(libs.findLibrary("junit.jupiter.api").get())
                        implementation(libs.findLibrary("junit.jupiter.params").get())
                        runtimeOnly(libs.findLibrary("junit.vintage.engine").get())

                        implementation(libs.findLibrary("kotest.runnerJunit5"))

                        implementation(libs.findLibrary("mockk").get())
                    }
    }
}
Gradle complaints that
kotest.runnerJunit5
is not found, but I have no idea as it should have no typo and it works before moving into convention plugin How to resolve these issue? thanks a lot