Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document editors (metals) support for cross-built projects #111

Open
jto opened this issue Nov 30, 2020 · 9 comments
Open

Document editors (metals) support for cross-built projects #111

jto opened this issue Nov 30, 2020 · 9 comments

Comments

@jto
Copy link

jto commented Nov 30, 2020

AFAIK there's no documentation available rn about using an editor (vscode) together with metals and have support for both Scala 2.x and Scala 3 in a single project. It would be nice if that rather common use case was supported and documented.

@adpi2
Copy link
Member

adpi2 commented Nov 30, 2020

I agree that we are lacking documentation on this side. But it is a general concern about cross-built project (version and platform).

@tgodzik Don't you think it should be documented in the Metals website? This way we could add a link from here and maybe elaborate further for the context of the migration.

@tgodzik
Copy link

tgodzik commented Nov 30, 2020

Not sure where to add it, we are saying here that Scala 3 is supported. We could add it also to overview, but the default behaviour is that Metals supports multiple versions at the same time.

We could add a mention in migration guide that multiple versions are supported and link to Metals with a comment to check exactly what is supported.

@jto
Copy link
Author

jto commented Dec 1, 2020

Thanks for your replies.

Metals does support both languages out of the box but as far as I can tell, it does not support a single project having sources in both Scala 2 and Scala 3. ie. if you have macros for both languages in different folders (src/scala-2 and src/scala-3).

Maybe something needs to be configured or a specific setting set in sbt, but I could not get it working.

@adpi2
Copy link
Member

adpi2 commented Dec 1, 2020

Metals does support both languages out of the box but as far as I can tell, it does not support a single project having sources in both Scala 2 and Scala 3. ie. if you have macros for both languages in different folders (src/scala-2 and src/scala-3).

I guess you are using a crossScalaVersions which is a stateful way of cross building (doc in sbt).

It means that, at any given time, sbt only knows about one scalaVersion and consequently bloopInstall configure Bloop for that single version. If you run ++<scalaVersion, Bloop won't be aware of it until bloopInstall is run again (or Import build in Metals).

It is slightly better with sbt as the build server because Metals will always be in-sync with sbt when compiling. But you still need to re-import the build so that Metals is aware of the new scala-version source directory. (That can be improved in future versions with buildChange notification in BSP, that is not yet supported by sbt).

Using sbt-projectmatrix (doc here) works a lot better with Metals because it creates one project (one BSP build target) for each scalaVersion.

So yes we should document that sbt-projectmatrix is well supported by Metals but crossScalaVersion is not really.

@tgodzik
Copy link

tgodzik commented Dec 1, 2020

We could try to always run +bloopInstall, but we would need to do a change in Bloop to generate separate build targets for each scala version. It should be simple enough though.

@jto
Copy link
Author

jto commented Dec 1, 2020

Indeed I'm using crossScalaVersions. I would guess most cross-built projects out there do the same so it'd be great if it could "just work".

@sjrd
Copy link
Contributor

sjrd commented Dec 1, 2020

While all of the above is true, and it would be nice if it worked, none of this is specific to Scala 3. If you have sources in scala-2.12 and scala-2.13, only one of those will be recognized by Metals. I don't think IntelliJ fares any better.

@jto
Copy link
Author

jto commented Dec 1, 2020

I did not know that. Although while it's correct it does not make it any less of an issue.

You are less likely to run into the issue between Scala 2.12 and 2.13 bc. they are mostly compatible. OTOH If you cross-build for 2.13 and 3.0, you are almost guaranteed to run into this since the languages are so different. I worry that this lack of ergonomics will in practice hinder the work to cross-publish and in the end encourage libs maintainers to just stick to Scala 2.

@tgodzik
Copy link

tgodzik commented Dec 1, 2020

@jto You are totally right. I think we should be able to work on it soon. Followed up with an issue here scalameta/metals#2287

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants