Hopefully tossing out a line here for some insight...
# gradle
b
Hopefully tossing out a line here for some insight… I am making a
java-gradle-plugin
and I need it to have reference to some of the classes inside of the
multiplatform
plugin. I have the plugin working 100% if I use the
kotlin("jvm")
plugin, but as soon as I switch to
multiplatform
I get class implementation not found in the plugin, and unzipping the output jar in the gradle cache, has none of the java components, just meta data. Is anyone aware of how I can override the publishing of the multiplatform targets (atleast one is required) so that it can use the plugin output rather than the multiplatform output? I Only need access to the classes from the multiplatform plugin, no outputs from it itself (or publishing for that matter)
t
I think you plugin should add
compileOnly
dependency for kotlin gradle plugin:
Copy code
compileOnly(kotlin("gradle-plugin", <plugin_version>))
b
I currently have my
implementation(kotlin("gradle-plugin", version))
in a buildSrc, so I would need to re-add to classpath anyways?
I guess I’m unsure what the compileOnly would fix ehre.
t
let me clarify - you are writing Gradle plugin and want to use some classes from kotlin Gradle plugin?
b
Specifically I would like to use classes such as:
Copy code
org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension

org.jetbrains.kotlin.gradle.dsl.plugin.mpp.Framework

org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask
Classes implemented by the plugin, but don’t actually need the plugin.
t
then add
compileOnly
dependency into plugin module
dependencies { .. }
block and wrap code that calls KMMGP classes with
project.plugins.withId("org.jetbrains.kotlin.multiplatform") { // your code here }
. Why
compileOnly
? Then you plugin will not bring as a dependency specific version of Kotlin Gradle Plugin, but still will react if user will explicitly add it to the buildscript.
b
I definitely understand your point now. Thank you. I knew that there was a way to have proper reference. Thank you