i have cloned this <intellij-platform-plugin-templ...
# jewel
m
i have cloned this intellij-platform-plugin-template repo and try to integrate jewel following the README but then this ExceptionInInitializerError happens. Am i missing something ?
s
We've seen that error but haven't had time to look too much into it. It looks like it's a classloading issue that happens when the coroutines dependency is mistakenly provided via Jewel (it probably is a Gradle configuration error on our side). Can you try to exclude by hand all coroutines dependencies from your Gradle dependencies that aren't coming from the IJ platform?
👀 1
m
sure, let me try it
h
I just started using jewel for my plugin yesterday. I think the root cause seems like this call is expected to run on coroutine. So, when I wrapped my Compose code with launch { } (just to test) then crash went away. So, progress but Compose UI is not rendering. So, will continue looking further. @seb I really want to get this working (as this is a great tool), so lmk if there are other things you want me to try.
Copy code
class CodeReplicatorToolWindow(toolWindow: ToolWindow) {

    private val service = toolWindow.project.service<CodeReplicatorProjectService>()

    @OptIn(ExperimentalJewelApi::class)
    fun getContent() = JBPanel<JBPanel<*>>().apply {
        // FIXME testing workarounds for SwingComposeBridge construction arg crash
        GlobalScope.launch(Dispatchers.Main) {
            // We need to make sure this is done before Compose is attached.
            // The operation is idempotent, so we can safely do it every time.
            enableNewSwingCompositing()

            val composePenal = JewelComposePanel {
               // Compose code ...
            }
            add(composePenal)
        }
    }
}
s
The call to enableNewSwingCompositing() can be done from anywhere (including the main function, if you have one) fwiw
It only calls System.setProperty
The only important thing is that it's called before creating the ComposePanel
h
It is the JewelComposePanel which calls SwingComposeBridge where it crashes
s
Creating and manipulating Swing components outside of the EDT can cause issues by the way. If this is an IJ plugin, you want to use Dispatchers.EDT
h
Good to know
s
I have never seen it cause crashes... If it does though the problem is in Compose, that function is only a convenience to set the flag that turns on the swing compositing. You could do the property setting by yourself (actually, maybe try?)
We just wanted to spare everyone — including ourselves! — the pain of memorising the property name :)
💯 1