https://kotlinlang.org logo
#compiler
Title
# compiler
d

Daniel Rampelt

10/14/2019, 3:46 PM
Hey, has anyone had any experience with a compiler plugin that works for both JVM and native? I've got a JVM plugin working but having some trouble getting plugins to work for native. I've been compiling against
kotlin-compiler-embeddable
(which has been working great for JVM) but it seems to have a bunch of dependencies remapped under
org.jetbrains.kotlin
. The problem is
konanc
, even when run from gradle just like I'm doing for JVM, doesn't seem to have those packages remapped so my plugin doesn't load since it's referencing the wrong classes. Is it possible to write a plugin that works for both JVM/native at the moment?
f

Foso

10/14/2019, 7:07 PM
Hi, i wrote a plugin library that can be used in both plugins. AFAIK you can't have one plugin for both. Because Native needs "org.jetbrains.kotlin:kotlin-compiler" and JMV/JS needs "org.jetbrains.kotlin:kotlin-compiler-embeddable". I also had problems with "wrong" classes. My problem was that the kotlin-compiler is using com.intellij.mock.MockProject but the kotlin-compiler-embeddable is using org.jetbrains.kotlin.com.intellij.mock.MockProject. But i was able to use my extension classes shared for both compilers.
d

Daniel Rampelt

10/15/2019, 12:13 AM
Ah yeah that's the same problem I'm having, guess I'll just have to write separate plugins then. Thanks!
s

Stumpos

02/12/2021, 9:43 PM
@Foso how were you able to get the plugin to expect the
intellij.mock.MockProject
rather than org.jetbrains.kotlin.com.intellij.mock.MockProject?
a

apatrida

09/23/2023, 11:53 AM
probably has a wrapper callback in each version of the plugin that the other code calls that abstracts that.
f

Foso

09/23/2023, 12:17 PM
This thread is very old, but in case someone is looking for a current answer: Since a while, you can use one plugin for all targets. I use the embeddable version for my projects.
a

apatrida

09/24/2023, 4:48 AM
great
thanks Jens
4 Views