I am writing a Gradle plugin that registers some t...
# multiplatform
k
I am writing a Gradle plugin that registers some tasks. The tasks currently are registered to depend on
kotlinCompile
. Is there a way to make it work with multiplatform in a generic name without me having to list all the possible names? Because it fails to find the task. On the JVM target it is
compileKotlinJvm
for example.
m
Maybe something like so:
Copy code
kotlin.targets.mapNotNull { it.compilations["main"]?.compileKotlinTaskName }
It's a bit weird though. Do you need access to the
.class
and
.klib
files?
Typically the outputs of the kotlin compiler are pretty hard to process unless you're the kotlin compiler yourself. Depending what your task is doing, you might be able to find better dependencies
s
We use this to match all KotlinCompile tasks:
Copy code
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>>().configureEach {
        ...
}
It works for js, jvm, common etc.
1
🙌 1
h
If you want to generate more source code, you should add a dependency to the sourceSet instead.
☝️ 1