metals icon indicating copy to clipboard operation
metals copied to clipboard

Allow multiple build targets for cross built project

Open tgodzik opened this issue 5 years ago • 6 comments

Describe the bug

Currently when a workspace is imported in sbt we only support one scala version, which might be problematic if we use different sources for each scala version. This becomes especially important for Scala 3, which can differ much from the Scala 2 code. In Metals we did a workaround by creating an additional non-publishable module. This however should not be needed.

We should be able to fix it possibly by:

  • adding scala version suffix to the target name in the Bloop sbt plugin - this is already being done in Mill
  • offer to run sbt +bloopInstall in case cross plugin is detected in the workspace (we could also make it an optional command)

To Reproduce

Steps to reproduce the behavior:

  1. Open scalameta/mdoc
  2. Import build
  3. Try navigating Scala 3 sources.

Expected behavior

Metals works in all sources in the workspace.

Installation:

  • Operating system: macOS/Windows/Linux
  • Editor: Visual Studio Code/Atom/Vim/Sublime/Emacs
  • Metals version: v0.9.6

Additional context

This came up as a follow up to https://github.com/scalacenter/scala-3-migration-guide/issues/111

Search terms

cross build targets

tgodzik avatar Dec 01 '20 16:12 tgodzik

Is there any progress on this? Currently working on projects that use 2.X and 3.X macros (via cross compile) is reminding me of the old days when I used vim and gcc ;)

froth avatar Jan 17 '22 12:01 froth

@froth no progress currently, but using project-matrix can work around it.

tgodzik avatar Jan 17 '22 13:01 tgodzik

Thanks, for the info. I will have a look if project-matrix makes my life easier :)

froth avatar Jan 17 '22 15:01 froth

Must I modify my build.sbt to have the scalaVersion I want to use in Metals, or can I switch on the fly somehow...? (I'm using sbt as my build server.)

SethTisue avatar Sep 08 '22 23:09 SethTisue

I guess I can go to the Metals tab, click on "Terminal", then run sbt -client ++3.1.3 or whatever version I want, then click "Connect to build server"; that causes the Scala version shown in the Metals Doctor to update.

If there's a better way, lmk.

SethTisue avatar Sep 08 '22 23:09 SethTisue

I guess I can go to the Metals tab, click on "Terminal", then run sbt -client ++3.1.3 or whatever version I want, then click "Connect to build server"; that causes the Scala version shown in the Metals Doctor to update.

If there's a better way, lmk.

For sbt that's probably the best way, we would need an additional endpoint for BSP to change it on the fly :thinking:

tgodzik avatar Sep 12 '22 19:09 tgodzik