Took more than expected to find time to work on th...
# jewel
s
Took more than expected to find time to work on this, but here is how you can use Jewel in 243 & 251 once we release the next version, 0.28 https://github.com/rock3r/jewel-ijp-template/tree/243-and-251-compat The example for now uses 0.27 on IJP 243, which has some significant differences from what’s on 251. 251 also doesn’t have all the 0.28 APIs and fixes available. I'm hoping they make it into 251.1, but the review and approval processes are taking longer than anticipated and are entirely internal to JetBrains, so I can't guarantee anything.
🙏 4
t
So IntelliJ 251 is already released. When i use this template would it already work for the current stable IntelliJ IDE? Or do we have to wait for the new version of Jewel. But when it is integrated into IntelliJ than we can not use a newer version of it. So we are tied to the version integrated into IntelliJ right?
s
If I understand what you're asking, the answer is "please hold off until 251.1 is out".
t
Ok i see. So we will not be able to support 251.0 Thank you for clarification. It is just i got today a mail from Jetbrains that my plugin should prepare for 252 😄
s
As I wrote above, this is only a proof of concept using what's out there today. 0.27, the latest available on 243 still, is quite different from what's on 251.0, which in turn is missing quite a lot of stuff compared to what we call 0.28. Moreover, 0.27 and what's on 251 today are not necessarily binary compatible; it might work for a simple example like the one in the repo, but it'll likely break for more complex stuff
🆗 1
That's why I'm trying to get 0.28 out ASAP, as that is binary compatible between 243 and 251.1
👌 1
Sadly things didn't line up to have this all done in 251.0; moving to the IJP uncovered a myriad issues in processes and infrastructure that delayed the release to this point
Things will get ironed out over time; doing releases like these across major IJP versions is unheard of at JetBrains and it's a lot more complex and time consuming that anyone imagined
The good news is that for 252 you shouldn't have to change anything from 251.1+, at least :D
t
Thank you very much for your effort. I know in the repo from Jewel it says clearly that it should not be used for production code. But i as an Android developer was not able to resist to use Compose for the UI for my Plugin 😄
plus1 1
s
I completely understand! This whole things exists pretty much because I also feel this way, and many others are also happy this is a possibility
Fwiw we're using Jewel in production in Studio, but that's a much more controlled environment than a 3p plugin needs to deal with
❤️ 1
f
Thanks for this @seb. We haven't updated since 0.25.0 ... at this point should we wait until 0.28 comes out or what upgrade path would you recommend (since we support both AS and IJ clients)?
s
Probably worth waiting for 0.28 at this point 🙂
thank you color 1
t
Hi i just try to get my plugin working with 251. So far i managed to get it working with one exception. But i was not able to get the 243 version working with the 0.28.0-243.27100 jewel-ide-laf-bridge. I get an error that some coroutine class could not be loaded because it was loaded already with an different interface. Full error message is in the thread. I already tried to exclude kotlinx
Copy code
implementation(libs.jewel.ideLafBridge) {
    exclude("org.jetbrains.kotlinx")
}
But without success. Just to be clear compiling and building the plugin is working. But when the Compose UI is shown i get this runtime error.
.PluginException: Cannot create editor by provider de.drick.compose.hotpreview.plugin.HotPreviewSplitEditorProvider ...
Copy code
Caused by: com.intellij.diagnostic.PluginException: Cannot load class kotlinx.coroutines.CoroutineScope (
  error: loader constraint violation: loader com.intellij.ide.plugins.cl.PluginClassLoader @2825eb60 wants to load interface kotlinx.coroutines.CoroutineScope. A different interface with the same name was previously loaded by com.intellij.util.lang.PathClassLoader @7ef20235. (kotlinx.coroutines.CoroutineScope is in unnamed module of loader com.intellij.util.lang.PathClassLoader @7ef20235),
  classLoader=PluginClassLoader(...)
)
s
When that happens is because you're leaking external coroutines into your plugin classpath somehow. The fix is to run a Gradle scan and see where they're coming from, then add an exclude to the dependency that leaks them in (which you've done). IJ 243.6 already has Jewel in the platform, so you should not bring in the bridge dependency there. You should use the platform one. However, if at all possible, I'd recommend setting the sinceBuild to 251.2, as we've seen people have weird issues in 243.6
Also, 0.28 on 243 probably has some issues, it should not have been published. The 0.28 release in general had some growing pain related to it being the first one being done from the IJP, and the person who did the release didn't know exactly what to look for when they tested. I am reasonably sure the next release will be better, as we did manage to test it. We'll also be dropping 243 support entirely with 0.29, fyi
t
Thank you very much for this information. So ok i see. So i think best option for me is to maybe only port some bugfixes back into my branch with Jewel 0.27.0 to support old IDEs and than cut the support. I think would be really nice for other developers if you could update your template and maybe if it is also referenced on the Jewel documentation.
One other question. I do have a special use case in my plugin. Because it shows previews of Compose code it can also be used to show previews for other Jewel based plugins. For this i need to import the following dependency: org.jetbrains.jewel:jewel-int-ui-standalone This is not working because the problem with the corotuine classloading. Is there an other way maybe without the standalone dependency to create a JewelTheme? (For this i am currently not able to connect the JewelTheme bridge to the running IDE. Maybe also not what is expected from a preview (Should be able to show previews for different themes maybe.) If you have time and want to have a look the gradle file with the dependency is here (Dependency is currently commented out) https://github.com/timo-drick/Multiplatform-Preview/blob/main/intellij-plugin/core/build.gradle.kts
s
> I think would be really nice for other developers if you could update your template and maybe if it is also referenced on the Jewel documentation. The template has a 251 + 243 branch that works and is mentioned in the readme on master — but more complex setups may not work. YMMV, unfortunately.e
As for the other question, we don't have a way to use standalone in the IDE, sorry. If you do figure out something do let me know, but otherwise, standalone dependencies are not designed to be used in the IDE at all.
t
Yes i know. But for Jewel 0.27.0 it just worked 😄
s
However, any usage of
foundation
and
ui
APIs should work as-is both in the bridge and standalone modes. If your previews do not call any standalone-only APIS (clearly recognisable from the package names) they should work without issues with the bridge theme, too.
0.27 might have worked, but it was never a design choice
It just happened to
We make no promises there
And in fact we are trying to actively discourage people from running standalone APIs in the IDE
Since the theme layer is the only thing that needs to change, and you can port Jewel UI as-is between standalone and bridge, that is considered enough for all relevant use cases
t
Ok maybe than i have to try to load the standalone theme with the preview classloader. But it is much more work and i am not sure if there are many devs out there using this previews for Jewel Plugin development.
s
You might be able to run standalone in the context of a UI preview, but you will need to have a completely separate classloader with all and only the standalone dependencies
Again, no guarantees, but it seems to me the separate classloader is a minimum requirement for previews in general anyway
Since the IDE's classloader will yell at you if you put random stuff in it anyway
t
Ok thank you. I will spent some time to get it working.
s
FWIW we're working on bringing Hot Reload to the IDE devkit to develop plugin UI in Compose/Jewel, but we do not have an ETA for it yet!
I know it doesn't 100% cover the same use cases as previews, but it might also cover the main ones. There is a bunch of overlap
t
Yes it would speedup the development. But for my preview plugin it was for free to also support jewel until now. But yea maybe i will find a way.
👍 1