bloop icon indicating copy to clipboard operation
bloop copied to clipboard

Implement build target change notifications

Open jvican opened this issue 5 years ago • 2 comments

Build target notifications are a BSP mechanism to notify the client the server has updated one of its project models and it has to update it accordingly. For example, whenever a new dependency is added to a project in a build tool, the client needs to know about it to index it and can get the notifications to start that process as soon as it's known by the BSP server. It is IMO one of the most importants features in the BSP protocol as it heavily improves the communication between client and server and allows instant and incremental reloads.

Bloop has to provide these build target notifications. This is a ticket to register my thoughts on how we can implement them in our current architecture.

I propose that whenever a BSP session is started, we start a task a long-running task that would file watch on all the JSON configuration files under the configuration directory (typically .bloop). The idea is that this talk will have a reference to the client so that it can push notifications on file change.

As we don't want to bother the client when a file change happens and doesn't modify anything, we should use all the machinery we have in Build.checkForChange to only update those configuration files that really changed (checkForChange hashes the contents to figure that out):

https://github.com/scalacenter/bloop/blob/master/frontend/src/main/scala/bloop/engine/Build.scala#L20-L62

After we recycle some of this logic, we should be in a solid position to provide build target change notifications reliably. There is however one missing piece: we need to properly cancel the file watcher whenever there has been a fatal error in the connection or the connection has ended.

jvican avatar Oct 18 '18 09:10 jvican

Does this affect if the CLI watch mode would watch build config files?

nafg avatar Feb 07 '19 22:02 nafg

It could make it easier, but it's not planned (for now) to make the CLI watch build configuration files.

jvican avatar Feb 11 '19 08:02 jvican