How to get Plugin A to use a BuilderService from Plugin B 关注
I’m working on a change to the bazel plugin to allow it to delegate compilation of scala code to the scala plugin.
I found https://github.com/JetBrains/intellij-scala/blob/idea222.x/scala/compiler-jps/src/org/jetbrains/jps/incremental/scala/ScalaBuilderService.scala but I don’t know how I can get access to it from the bazel plugin (I don’t really understand the JPS thing but that might not be the issue).
Relatedly but more scala plugin specific- I also found https://github.com/JetBrains/intellij-scala/blob/idea222.x/scala/scala-impl/src/org/jetbrains/plugins/scala/compiler/CompileServerManager.scala but I can’t really find how the scala plugin uses the compile server.
Would appreciate any thoughts on 1 (how to use ScalaBuilderService in a separate plugin) or on 2 (how scala plugin uses compile server and if I can do the same from a separate plugin)
I can't answer your questions directly (my colleague will), but it may interest you that bazel-bsp as of v2.2.0 is able to use bloop for compilation.
Regarding the Scala Compile Server.
One aspect is managing its lifecycle, because the Compile Server is an external JVM process. This is done through a combination of both
The second aspect is sending compilation requests to it. This is done mostly through the
RemoteResourceOwnertrait, and the classes in the same
Unfortunately, the code has been written without an intention to use it outside the project. The API has not been made with external usage in mind. It should also be considered unstable and could be broken at any time, so please use with caution.
As far as code examples that you can take a look at go, please consult `org.jetbrains.jps.incremental.scala.ScalaBuilder#compile`. This code should be a full end to end set up for connecting to the compile server process and sending compilation requests. It is how the JPS subsystem of IDEA (indirectly) communicates with the compile server and does compilation.
The `ScalaBuilder` in turn calls `org.jetbrains.jps.incremental.scala.remote.RemoteServer#compile`, which is a concrete implementation of the `org.jetbrains.jps.incremental.scala.remote.RemoteResourceOwner` interface, which houses the low level protocol of sending bytes and communicating with the process.
Hope some of this can be of help and thank you for the question.
Thank you both!
Justin- I took the liberty of moving that discussion to bazelbuild slack (https://bazelbuild.slack.com/archives/C025SBYFC4E/p1659615137620589 if anyone is interested).
I fully understand I'm walking in unclear territory; Thanks for the clarification.
Can I use `ScalaBuilder` from the bazel plugin (if it adds a dependency on the scala plugin) or do I need to implement something like it myself and talk to `org.jetbrains.jps.incremental.scala.remote.RemoteServer#compile` myself?