com-lihaoyi / mill

Your shiny new Java/Scala build tool!
https://mill-build.com/
MIT License
1.99k stars 303 forks source link

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

Open lolgab opened 1 month ago

lolgab commented 1 month ago

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:

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 commented 1 month ago

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 commented 1 month ago

@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 commented 1 month ago

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 commented 1 month ago

Started working on adding the message to the official BSP protocol: https://github.com/build-server-protocol/build-server-protocol/pull/673

lefou commented 1 month ago

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

@lolgab Thank you! ❤️