kotlinc-js 1.8 doesn't seem to support IR - kotlin-js

When compiling using the kotlin 1.8 sdk, for example :
kotlinc-js -version
One gets the following:
info: kotlinc-js 1.8.0 (JRE 19.0.1)
error: ==========
This project currently uses the Kotlin/JS Legacy compiler backend, which has been deprecated and will be removed in a future release.
Please migrate your project to the new IR-based compiler (https://kotl.in/jsir).
Because your build tool will not support the new Kotlin/JS compiler, you will also need to migrate to Gradle.
You can continue to use the deprecated legacy compiler in the current version of the toolchain by providing the compiler option -Xuse-deprecated-legacy-compiler.
==========
The implication of this seems to be that the IR js compiler can be used from Gradle - which seems a really annoying limitation. Is this really this case?

Related

How to set the version of the Kotlin compiler in a non-Android project?

I am running into a compile error when trying to compile a project with Kotlin and Compose Multiplatform, I think due to the Compose 1.1.0 compiler extension not being compatible with Kotlin 1.6.21. Even though I set my Kotlin plugin version to 1.6.10:
plugins {
idea
kotlin("jvm") version "1.6.10"
id("org.jetbrains.compose") version "1.1.0"
}
I get this error:
Kotlin: kotlinc-jvm 1.6.21-release-334 (JRE 15+36-1562)
Kotlin: [Internal Error] java.lang.IllegalStateException: The provided plugin androidx.compose.compiler.plugins.kotlin.ComposeComponentRegistrar is not compatible with this version of compiler
I can't figure out how to set the version of the Kotlin compiler that is used. From the log above the error, I can see it's using version 1.6.21-release-334, rather than some 1.6.10 version.
An alternate possible solution would be to change the version of the Compose Kotlin Compliler plugin to a more recent alpha or beta version that supports Kotlin 1.6.21, but I can't figure out how to do that either. In an Android project, you would use:
android {
composeOptions {
kotlinCompilerExtensionVersion = "1.2.0-beta03"
}
}
However, I would rather solve this by setting the Kotlin compiler so I won't run into the issue again whenever the latest version of Kotlin outpaces the compatibility of the Compose Multiplatform Kotlin Compiler Plugin.
The main idea I was thinking about is that there are some other places in the existing project where the old version 1.6.21 was used or some other setups that require that version or maybe an old cache. So basically need to clean the project, even delete the .idea directory of the project, and check other places where the old version can be set. After that reopen the project, do cleanup, sync and rebuild it.

Class 'my.example.Class' is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler

I am using IntelliJ, I published a library but when I try to use it, I get the warning: Class 'my.packge.MyClass' is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler.
I am using the same build.gradle.kts on both projects, same kotlin version (1.6.21).
The weirdest part is that if I do build, the projects build just fine without any error.
Any suggestions on what could be going on?
Seem to be Kotlin's bug:
https://youtrack.jetbrains.com/issue/KTIJ-21563
Watch it in order to be notified once it has updates. See this article if you are not familiar with YouTrack.

Cant build libgdx project

I got the error that states "Unsupported class file major version 57" while trying to build LibGdx project, along with few other notifications. Same happens when trying to build using IntelliJ idea.
I have no idea how to fix that.
"Unsupported class file major version 57" means your version of Java is incompatible with the one with which Gradle was compiled. You have to make sure that the Java version you are using is compatible to the Gradle version you are using. I guess you have either to downgrade your Java version or upgrade the Gradle version.

How to update kotlin compiler embedable?

I have common library with own libraries and build tools for gradle. Like SDK. I updated kotlin to 1.2.71. All ok. I also updated kotlin dsl to newest RC release(no effect).
Then I have projects, which are using this mine SDK. Problem ocurred, when I switched to version 1.2.71 on those projects, because "BuildUtilKt.makeModuleFile" was removed.
Unable to find method 'org.jetbrains.kotlin.incremental.BuildUtilKt.makeModuleFile(Ljava/lang/String;ZLjava/io/File;Ljava/lang/Iterable;Ljava/lang/Iterable;Ljava/lang/Iterable;Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/io/File;'.
or
Unable to find method 'org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments.setCommonSources([Ljava/lang/String;)V'.
I know how to remove dependencies, when I have it in compile, but I don't know where from I am getting "kotlin-compiler-embeddable:1.2.41"
Tried:
- compileOnly("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.2.71") in buildSrc
- runtime "org.jetbrains.kotlin:kotlin-compiler-embeddable:1.2.71"
it doesn't work.
Here are printed dependencies: gist

The binary version of its metadata is 1.0.1, expected version is 1.1.0

In intellij idea 16 EAP 144.3357.4 I have a pure Kotlin cmd project currently refusing to run with this error:
The binary version of its metadata is 1.0.1, expected version is 1.1.0
The project runs on the command-line - I invalidated caches and restarted Idea - nothing helped. Anyone had the same problem and found a way to get it working?
The problem seems to be mismatch between the kotlin library used in your project and the version of the plugin are not compatible.
Check the Kotlin plugin version and you'll most likely see something similar to:
Version: 1.0.0-rc-1007-IJ143-11
Then check the version of the Kotlin libraries by looking into META-INF/build.txt or META-INF/MANIFEST.MF and it'll most likely be other version like 1.0.0-beta-4589.
To resolve the problem update Kotlin libraries to version 1.0.0-rc-1007 which can be found in this maven repository: https://dl.bintray.com/kotlin/kotlin-eap.
Kotlin compiler marks each .class with #kotlin.Metadata to indicate, among others:
The version of the bytecode interface (naming conventions, signatures) of the class file annotated with this annotation.
That is how the compiler detected incompatibilities.