Skip to content

[BSP] Support buildTarget/wrappedSources for build scripts - #3195

Closed
lolgab wants to merge 3 commits into
mainfrom
bsp-wrappedSources
Closed

lolgab wants to merge 3 commits into
mainfrom
bsp-wrappedSources

Conversation

@lolgab

@lolgab lolgab commented May 30, 2024 •

Copy link
Copy Markdown
Member

scala-cli supports a bespoke extension to the the build server protocol.
This extension allows the support of Scala scripts. Scala scripts
are Scala code which is then wrapped at build time by some Scala
code to make them valid Scala code.
scala-cli-bsp's buildTarget/wrappedSources allows build tools to
give the following information:

  • the scala script file
  • the generated scala file generated from the script
  • the string that is added on the top of the file
  • the string that is added on the bottom of the file

This PR adds Virtuslab's scala-cli-bsp library to the bsp worker module,
and implements the handler for the buildTarget/wrappedSources call.
To make the information available, it changes the return type of
generateScriptSources in MillBuildRootModule to return, together
with the PathRef of the destination folder, the four elements
described above, so it can be used by BSP.

lolgab added 2 commits May 31, 2024 01:13
scala-cli supports a bespoke extension to the the build server protocol.
This extension allows the support of Scala scripts. Scala scripts
are Scala code which is then wrapped at build time by some Scala
code to make them valid Scala code.
scala-cli-bsp's buildTarget/wrappedSources allows build tools to
give the following information:
- the scala script file
- the generated scala file generated from the script
- the string that is added on the top of the file
- the string that is added on the bottom of the file
This PR adds Virtuslab's scala-cli-bsp library to the bsp worker module,
and implements the handler for the buildTarget/wrappedSources call.
To make the information available, it changes the return type of
`generateScriptSources` in `MillBuildRootModule` to return, together
with the `PathRef` of the destination folder, the four elements
described above, so it can be used by BSP.
@lefou

lefou commented May 31, 2024 •

Copy link
Copy Markdown
Member

That BSP extension looks new to me, which surprises me, since I try to follow the BSP development closely. I think making a bespoken BSP extension without a proper specification the status quo (by supporting it in scala-cli and a major BSP client in the Scala world) is a worst case scenario and will render the whole BSP idea to nonsense. We should strive for getting this extension into the BSP spec. Therefore, please provide a link to the BSP issue, where this extension is discussed. If there is none, we should create one and link all existing implementations and discussions. Further discussion how the extension should behave should continue there (e.g. not in some discord channels). As it looks like, the extension is already developed, so all that is left is to formalize it in the spec and properly support it with a capability flag.

@lolgab

lolgab commented May 31, 2024

Copy link
Copy Markdown
Member Author

@lefou Sure, I don't have anything against making the extension an official part of BSP.
My focus is first to make sure this works.
I believe it wasn't added as part of the protocol yet because it is an experimental feature and needed validation. Having two different build tools supporting it is validation that it is general enough to be added to the protocol.

@lefou

lefou commented May 31, 2024

Copy link
Copy Markdown
Member

Yeah, but there is not a single trace in the BSP project, not even a discussion or a wiki. What a waste of developer resources (you never know who else fiddles with this stuff) and also miss of valuable input (Should we put this behind a capability? Yes. Should we define a new supported langauge for that? No.)

@lolgab

lolgab commented May 31, 2024

Copy link
Copy Markdown
Member Author

Started working on adding the message to the official BSP protocol: build-server-protocol/build-server-protocol#673

@lefou

lefou commented May 31, 2024 •

Copy link
Copy Markdown
Member

Started working on adding the message to the official BSP protocol: build-server-protocol/build-server-protocol#673

@lolgab Thank you! ❀️

@lihaoyi

lihaoyi commented Apr 8, 2025

Copy link
Copy Markdown
Member

Closing due to inactivity

@lihaoyi lihaoyi closed this Apr 8, 2025
@lefou

lefou commented Apr 8, 2025

Copy link
Copy Markdown
Member

Sorry @lolgab for me being naive and thinking the BSP project is the way to go. (Meanwhile, I think it's a corporate project serving the interest of some vendor. Decisions seem to happen somewhere else.)

I think we might support this feature nonetheless, as it might also fix the issue we have in Mill with our generated script sources. IDEA and probably Metals often jumps to the derived sources instead to the originals. If we can fix that for at least Metals users, this would be great.

@lihaoyi
lihaoyi deleted the bsp-wrappedSources branch May 16, 2025 11:24
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

Successfully merging this pull request may close these issues.

3 participants