Hey, folks! In my IntelliJ Platform Gradle Plugin,...
# plugin-development
j
Hey, folks! In my IntelliJ Platform Gradle Plugin, I've decided to bump the Gradle version from
8.14.3
to
9.0.0-rc-4
. When running integration tests against Gradle 8.x, the plugin fails on
java.lang.NoSuchMethodError
and
java.lang.NoClassDefFoundError
. In my code, I rely on
sequenceOf()
and
yield()
, whose signatures slightly changed in Kotlin 2.0:
sequenceOf()
Copy code
* Exception is:
java.lang.NoSuchMethodError: 'kotlin.sequences.Sequence kotlin.sequences.SequencesKt.sequenceOf(java.lang.Object)'
	at org.jetbrains.intellij.platform.gradle.resolvers.path.ModuleDescriptorsPathResolver.<init>(ModuleDescriptorsPathResolver.kt:19)
	at Build_gradle.<init>(build.gradle.kts:53)
yield()
Copy code
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':signPlugin'.
....
Caused by: java.lang.NoClassDefFoundError: kotlin/coroutines/jvm/internal/SpillingKt
	at org.jetbrains.intellij.platform.gradle.tasks.SignPluginTask$arguments$1.invokeSuspend(SignPluginTask.kt:208)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
My first though was to build the Gradle plugin targeting Kotlin 1.8 (we support Gradle 8.5+) using:
Copy code
kotlin {
    jvmToolchain(17)

    compilerOptions {
        apiVersion = KotlinVersion.KOTLIN_1_8
        languageVersion = KotlinVersion.KOTLIN_1_8
    }
}
but this didn't really help. Any ideas on how to deal with that?
m
Probably you'll need to set
coreLibrariesVersion
👆 1
v
Ah, the joy of not using Java for a public plugin. 😄
1
m
The fact that
apiVersion
doesn't cover this is a major oversight IMO but I'll still have this over semi colons any time ;-)
There are a bunch of YouTracks around this
This helps
Copy code
tasks.withType<KotlinCompile>().configureEach {
    compilerOptions {
        apiVersion.set(KotlinVersion.KOTLIN_1_8)
        languageVersion.set(KotlinVersion.KOTLIN_1_8)
    }
}
v
Another inheritance from Java :-D It is like target compatibility. Java became sane and added
-release
. 🤷‍♂️
v
apiVersion is pretty much the same as Java's release
m
The big difference is that the Kotlin runtime lib is not bundled
v
> apiVersion is pretty much the same as Java's release > > I thought so too, but then why do you additionally need the
coreLibrariesVersion
to compile against the old API? 🤔
m
Because it's bonkers 🙃
The current situation is confusing for no good reason IMO
@Jakub Chrzanowski did you fix your issue? Could it be that some other dependency pulls
kotlin-stdlib:2.2
in your compile classpath?
v
Ah, so it wants to be like
-release
, but isn't, I see. :-)
m
There's no 1:1 mapping between the JVM and Kotlin flags. One has an execution environment and a bundled runtime. The other reuses the JVM execution environment and has an unbundled runtime. Kotlin also has compile-time requirements that are different from runtime (
languageVersion
). It's tempting to try to map the concept but I find it easier to look at them differently. Why there is both
apiVersion
and
coreLibrariesVersion
is a mistake IMO
KGP should probably not add a dependency if the user specified it explicitely
And
apiVersion
should control the version of stdlib or so (basically KT-58998)
j
@Martin I'm using
kotlin-dsl
which overrides on the task's level (ref) the
apiVersion
and
languageVersion
set via extension.
👌 1
m
👍