metals-feature-requests icon indicating copy to clipboard operation
metals-feature-requests copied to clipboard

Support multiple output target paths from BSP

Open aishfenton opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe.

For build tools that support large monorepos (such as Bazel, Blaze, Pants, Buck, etc) it's typical to have multiple output paths, per build target. Classes, and semanticdb files, are partitioned into different chunks (for different subdirectories), and stored in different places across the filesystem.

Currently Metals is assuming that a single output path is used per BuildTarget (in ScalacOptionsItem.classDirectory). This means that these tools have to resort to ad-hoc solutions, such as copying (or linking) these targets into a single directory.

Describe the solution you'd like

Instead of using a single target output path, support a List[Uri] output locations instead. Either ScalacOptionsItem could be be modified to support this. Or the meaning of OutputPathsRequest could be revisited.

Describe alternatives you've considered

The alternative is to copy (or soft link) the various output paths into a single directory for Metals.

This has a few downsides:

  • Since this is a problem for several build tools, it's undesirable to push the solution to each of them (where it'll have to be re-solved each time).
  • In some cases, the solution can be expensive. Sometimes the only option is to copy the separate output locations, into the single directory. This is very expensive for large monorepos.

Additional context

No response

Search terms

Bazel, classDirectory

aishfenton avatar Feb 14 '23 01:02 aishfenton

Opened an issue on the BSP spec, as it'd need to be addressed there too.

aishfenton avatar Feb 14 '23 01:02 aishfenton

This limitation affects also the Mill BSP implementation. Mill is generating semanticDB into a different location than the compiled class-files and needs to work around this issue by copying all files into a third directory.

lefou avatar Feb 14 '23 08:02 lefou