Closed sureshg closed 2 days ago
Could you try adding kotlin-dsl
with apply false
to the root project? isAtLeastKotlinVersion
will only be called if either the org.jetbrains.kotlin.jvm
or org.jetbrains.kotlin.multiplatform
is applied to the project. The kotlin-dsl
plugon will apply kotlin jvm so that the check is executed is intentional. My theory is that because the publish plugin is on the root project classloader but kotlin-dsl
only on the plugin project that it can't see the Kotlin plugin properly.
Could you try adding kotlin-dsl with apply false to the root project?
Still have the same error.
My theory is that because the publish plugin is on the root project classloader but kotlin-dsl only on the plugin project that it can't see the Kotlin plugin properly.
Yeah, somehow worked around this by doing something like below. Not sure whether it's a good solution or not.
# build-logic plugin
implementation("${libs.build.kotlin.dsl.get().module}:${expectedKotlinDslPluginsVersion}")
// Plugin Project
plugins {
// Just apply with `kotlin-dsl` id.
id("org.gradle.kotlin.kotlin-dsl")
embeddedKotlin("plugin.serialization")
com.github.`ben-manes`.versions
com.diffplug.spotless
gg.jte.gradle
plugin.publishing
}
That workaround is perfectly fine. The altnernative would be to add a dependency on the publish plugin in build logic. Both achieve that the Kotlin plugin and the publish plugin are part of the same classloader and can see each other.
@gabrielittner thanks..Does it make sense to use java reflection to avoid these class loader issues for getting the plugin version?..something like
plugins.withId("org.jetbrains.kotlin.multiplatform") {
val pluginVersion = javaClass.getMethod("getPluginVersion").invoke(this).toString()
}
I have a small multi module project, where the root
build.gradle.kts
has the following plugin configurationThe root project doesn't have any publishable artifact, but adding the vanniktech plugin just to avoid some weird class loading issue. One of the modules is a project with
kotlin-dsl
plugin appliedplugins/build.gradle.kts
When I run the build with this configuration, the plugin throws following error.
IIUC, correctly, kotlin plugin is not a requirement for this plugin and should gracefully fall back to no-op.