JetBrains / sbt-idea-plugin

Develop IntelliJ plugins with Scala and SBT
Apache License 2.0
97 stars 28 forks source link

A rudimentary support for Scala 3 #111

Closed azolotko closed 4 months ago

unkarjedy commented 3 years ago

related https://youtrack.jetbrains.com/issue/SCL-19086

azolotko commented 3 years ago

@unkarjedy ~might be also related to https://github.com/sbt/sbt/issues/6628~

Never mind, that issue is invalid.

izzyreal commented 1 year ago

Can someone comment on the status of this PR?

@jastice I suppose we're awaiting @azolotko's reply to https://github.com/JetBrains/sbt-idea-plugin/pull/111#discussion_r992417083 ?

jastice commented 1 year ago

Can someone comment on the status of this PR?

@jastice I suppose we're awaiting @azolotko's reply to #111 (comment) ?

Yes, though of course you can check it yourself :)

izzyreal commented 1 year ago

Can someone comment on the status of this PR? @jastice I suppose we're awaiting @azolotko's reply to #111 (comment) ?

Yes, though of course you can check it yourself :)

Yeah I was thinking the same 😄 👍 I primarily wanted to confirm that this PR is still relevant. Thanks!

azolotko commented 1 year ago

Can someone comment on the status of this PR?

@jastice I suppose we're awaiting @azolotko's reply to #111 (comment) ?

Oops 😬

I’ll give it another try tomorrow.

izzyreal commented 1 year ago

Can someone comment on the status of this PR? @jastice I suppose we're awaiting @azolotko's reply to #111 (comment) ?

Oops 😬

I’ll give it another try tomorrow.

That would be great, but I'm also happy to look into it. I'll keep an eye out on this PR. Thanks in advance!

azolotko commented 1 year ago

Ok, I've rebased the PR and given it another try.

Here's a sample project that uses a locally built snapshot of sbt-ide-plugin from the azolotko:rudimentary-scala-3-support branch. The project uses Scala 3.3.0 and accesses both Scala 2 and Scala 3 standard library classes.

From the test run log:

2023-09-01 18:40:46,784 [  15818]   INFO - STDOUT - Illegal command line: hello from Scala 3 std lib
2023-09-01 18:40:46,784 [  15818]   INFO - STDERR - hello from Scala 2 std lib 

LGTM

unkarjedy commented 1 year ago

@azolotko Could you please also describe in words which issue this PR tries to fix? I don't recall any existing issues related to lack of Scala 3 support, which would be related to sbt-idea-plugin.

azolotko commented 1 year ago

When I initially created this PR, the problem was in sbt-idea-plugin not bundling Scala 3’s std lib, only Scala 2’s one.

Op vr 1 sep. 2023 om 19:09 schreef Dmitrii Naumenko < @.***>

@azolotko https://github.com/azolotko Could you please also describe in words which issue this PR tries to fix? I don't recall any existing issues related to lack of Scala 3 support, which would be related to sbt-idea-plugin.

— Reply to this email directly, view it on GitHub https://github.com/JetBrains/sbt-idea-plugin/pull/111#issuecomment-1703075548, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA26WB6ZGIRB22S4HX5V4TXYIJGFANCNFSM5CNV4IYQ . You are receiving this because you were mentioned.Message ID: @.***>

unkarjedy commented 1 year ago

Hm, I never thought of it before, but it looks like we have a broader issue here. I am now not sure if users of sbt-idea-plugin should be able to specify the exact Scala version (which is now the case, example 1, example 2)

This can lead to multiple scala-libraries in the classpath. For example, if the plugin depends on Scala Plugin or simply if the user installs multiple plugins which were built using sbt-idea-plugin. This can lead to errors at runtime.

On the other hand, there can be plugins developed with sbt-idea-plugin which do not depend on Scala Plugin and can work independently. So it looks like some plugins need to publish scala library (libraries) with them anyway.

So taking that, it's possible to have multiple plugins built using sbt-idea-plugin with multiple scala library jars, it would be at least good if those library versions are the same for all plugins.

Some thoughts on how we could achieve that:

  1. Extract responsibility of defining Scala 2, Scala 3 version into sbt-idea-plugin
  2. Change the versioning scheme for the sbt-idea-plugin closer to IntelliJ IDEA (2023.2.x, 2023.1.x)
  3. Do not change the "major" Scala 3 version in the same major version of sbt-idea-plugin. Note, the issue is less actual for Scala 2, because there will be no Scala 2.14, and changes in 2.13.x are not expected to break anything (though in theory there might be some issues even due to different minor issues)

This way we can be "more sure" that scala library versions from different plugins are the same.


UPD I just remembered that in IntelliJ IDEA, a special class loader is used for plugins (PluginClassLoader). It is isolates plugins classpaths to avoid runtime errors. So the issue described above is mostly actual if a plugin depends on Scala Plugin (e.g. "Big Data Tools" or "IntelliJ ZIO").

An alternative could be to do nothing. But in this case, every plugin developer will need to ensure they use the same Scala version as is used in Scala Plugin. (it's mostly about Scala 3 version)


@jastice, @pavelfatin Maybe you could also provide some thoughts on it?

unkarjedy commented 4 months ago

I will manually merge this PR and run it through our internal CI. This issue might still be relevant though: https://github.com/JetBrains/sbt-idea-plugin/pull/111#issuecomment-1708504077

unkarjedy commented 4 months ago

@azolotko Thanks for the PR, even though it took so long to merge it!

unkarjedy commented 4 months ago

It's merged and published in 3.26.0