Anyone might have an idea why I can't specify jvmTarget with Gradle 7.6?
d
Anyone might have an idea why I can't specify jvmTarget with Gradle 7.6?
s
m
If you're using multiplatform, you certainly need to cast to
KotlinJvmOptions
or so
Actually that might also be the case for non-multiplatform
KotlinCompile
is the "generic" task. Since it's shared with JS and native, it doesn't make sense for it to have
jvmTarget
t
better to use
KotlinJvmTarget
in this case
hopefully we publish KGP-api initial docs in 1.8.20 release so these interfaces would be more visible
d
How do I use KotlinJvmTask?
Ok... I think I got it:
Copy code
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile>().configureEach {
    compilerOptions {
        languageVersion.set(KOTLIN_1_9)
        freeCompilerArgs.set(listOf(
            "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
//            "-Xcontext-receivers"
        ))
        jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11)
    }
}
t
sorry, had a type - should be
KotlinJvmCompile
d
But this should really be documented somewhere... a google search doesn't pull this up either...
A google search is all mixed up with all the other methods I tried...
t
good point - we will try to improve our documentation on kotlinlang.org
d
Funny, even WITH that option I still get
Cannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
in my code using a certain library function...???
(in Intellij... I even tried resyncing from gradle files...)
t
and if you build your project in command line?
d
Using the build gradle task is working... it just seems like intellij is confused.
t
hm, how are you building in IDEA? via
Build -> Build project
? 🤔
d
No, using gradle
In the settings...
The i
t
try resync the project, if it will not help - reindex, if it will not help - open a YT issue with repro 🙂
d
The IDE underlines with red and gives that error... I resynced, didn't help, how do I reindex? Erasing .idea folder?
t
better via
File -> Repair IDE
d
Ok, it only started working after step3 of the repair ide action...
Nice to know about that option... I usually clean the ide cache which can potentially take a LOT of time... thanks!