Build Server Build Server Protocol and new Protocol and new IDEAs - - PowerPoint PPT Presentation

build server build server protocol and new protocol and
SMART_READER_LITE
LIVE PREVIEW

Build Server Build Server Protocol and new Protocol and new IDEAs - - PowerPoint PPT Presentation

Build Server Build Server Protocol and new Protocol and new IDEAs IDEAs 1 Justin Justin @ebenwert @ebenwert Build tools engineer at Jetbrains I work on the IntelliJ sbt integration I believe in tools before rules Obsession : build tools


slide-1
SLIDE 1

1

Build Server Build Server Protocol and new Protocol and new IDEAs IDEAs

slide-2
SLIDE 2

2

Justin Justin @ebenwert @ebenwert

Build tools engineer at I work on the IntelliJ sbt integration I believe in tools before rules Obsession: build tools complaints in Gitter Jetbrains

slide-3
SLIDE 3

3

Jorge Jorge @jvican @jvican

Devtools for ~2.5 years at I co-maintain Scala's incremental compiler (Zinc) I work on build tools and build servers scalac, compiler plugins and infrastructure Obsession: developer productivity Scala Center

slide-4
SLIDE 4

4

Agenda Agenda

  • 1. The BSP IDEA
  • 2. The BSP protocol
  • 3. The BSP integrations
slide-5
SLIDE 5

5

Goal Goal

  • 1. Explain why BSP solves a real problem
  • 2. Share our ndings with the audience
slide-6
SLIDE 6

6

How BSP came up How BSP came up

... ...

slide-7
SLIDE 7

7

Use case (I) Use case (I)

Language servers Language servers

slide-8
SLIDE 8

8

Use case (II) Use case (II)

Editors Editors

slide-9
SLIDE 9

9

Build tools Build tools

As the ultimate source of truth As the ultimate source of truth

slide-10
SLIDE 10

10

100 100 combinations! combinations!

slide-11
SLIDE 11

11

BSP BSP (Build Server Protocol) is an (Build Server Protocol) is an attempt to formalize the attempt to formalize the communication between communication between language language server/editors server/editors and and build tools build tools.

slide-12
SLIDE 12

12

«LSP LSP creates the opportunity to reduce creates the opportunity to reduce the m-times-n complexity problem of the m-times-n complexity problem of providing a high level of support for providing a high level of support for any any programming language programming language in any editor, in any editor, IDE, or client endpoint to a simpler m- IDE, or client endpoint to a simpler m- plus-n problem.» plus-n problem.»

  • - https://langserver.org/
  • - https://langserver.org/
slide-13
SLIDE 13

12 13

«BSP BSP creates the opportunity to reduce creates the opportunity to reduce the m-times-n complexity problem of the m-times-n complexity problem of providing a high level of support for providing a high level of support for any any build tool build tool in any editor, IDE, or client in any editor, IDE, or client endpoint to a simpler m-plus-n problem.» endpoint to a simpler m-plus-n problem.»

  • - Justin and Jorge
  • - Justin and Jorge
slide-14
SLIDE 14

13 14

«Bejeezus, I just want bloody fast and «Bejeezus, I just want bloody fast and correct compiles for my team.» correct compiles for my team.»

  • - Sam Halliday, serious devtools engineer
  • - Sam Halliday, serious devtools engineer
slide-15
SLIDE 15

15

Developer productivity engineers Developer productivity engineers

want solutions that are want solutions that are

  • 1. Extensible
  • 2. Easy to maintain
  • 3. And ideally
  • 1. Build tool independent
  • 2. Editor independent
slide-16
SLIDE 16

16

  • -- a/nothing.properties
  • -- a/nothing.properties

+++ b/bsp.properties +++ b/bsp.properties

  • build.tool.specific=true
  • build.tool.specific=true
  • one.time.effort=false
  • one.time.effort=false
  • shared.code=false
  • shared.code=false
  • robust=false
  • robust=false
  • easier.to.maintain=false
  • easier.to.maintain=false
  • easier.to.test=false
  • easier.to.test=false

+ build.tool.specific=false + build.tool.specific=false + one.time.effort=true + one.time.effort=true + shared.code=true + shared.code=true + robust=true + robust=true + easier.to.maintain=true + easier.to.maintain=true + easier.to.test=true + easier.to.test=true

slide-17
SLIDE 17

16 17

BSP Protocol BSP Protocol

slide-18
SLIDE 18

18

Fundamentals I Fundamentals I

  • 1. JSON-RPC-based protocol
  • 2. It has the notion of

Request/Response Bidirectional notications

slide-19
SLIDE 19

19

Fundamentals II Fundamentals II

  • 1. Modelled after LSP

Specication follows same format Client-driven design It reuses some LSP methods, e.g. window/logMessage textDocument/publishDiagnostics $/cancelRequest

  • 2. Aims to be implementable alongisde LSP
slide-20
SLIDE 20

20

Server lifetime Server lifetime

Firing up BSP server Firing up BSP server stdin stdin/stdout stdout TCP/UDP connections. TCP/UDP connections. Unix Sockets/Windows pipes Unix Sockets/Windows pipes Initializing BSP connection Initializing BSP connection Similar to TCP 3-way handshake Similar to TCP 3-way handshake Shutting down the BSP server Shutting down the BSP server

slide-21
SLIDE 21

21

Server lifetime Server lifetime

Request Request

Client Server build/initialize

trait InitializeBuildParams { def rootUri: URI def capabilities: BuildClientCapabilities } trait BuildClientCapabilities { def languageIds: List[String] }

slide-22
SLIDE 22

22

Server lifetime Server lifetime

Response Response

Server Client response back

trait InitializeBuildResult { capabilities: BuildServerCapabilities } trait BuildServerCapabilities { compileProvider: Boolean testProvider: Boolean textDocumentBuildTargetsProvider: Boolean dependencySourcesProvider: Boolean buildTargetChangedProvider: Boolean }

slide-23
SLIDE 23

23

Server lifetime Server lifetime

Notification Notification

Client Server build/initialized

trait InitializedBuildParams {}

slide-24
SLIDE 24

24

Server lifetime Server lifetime

Client Server build/shutdown

Client Server build/exit

slide-25
SLIDE 25

25

Core data structure Core data structure

A common notion of what a target is A common notion of what a target is across different build tools and language servers across different build tools and language servers

trait BuildTarget { def id: BuildTargetIdentifier def displayName: Option[String] def languageIds: List[String] def data: Option[Json] } trait URI { def uri: String } trait BuildTargetIdentifier { def uri: URI } Build tool module Build target IDE module

slide-26
SLIDE 26

26

workspace/buildTargets workspace/buildTargets

Client => Server

trait WorkspaceBuildTargetsParams {}

Server => Client

trait WorkspaceBuildTargetsResult { def targets: List[BuildTarget] }

slide-27
SLIDE 27

27

buildTarget/dependencySources buildTarget/dependencySources

Client => Server

trait DependencySourcesParams { def targets: List[BuildTargetIdentifier] }

Server => Client

trait DependencySourcesResult { def items: List[DependencySourcesItem] } trait DependencySourcesItem { def target: BuildTargetIdentifier def sources: List[URI] }

slide-28
SLIDE 28

28

buildTarget/compile buildTarget/compile

Client => Server

trait CompileParams { def targets: List[BuildTargetIdentifier] def arguments: List[Json] }

Server => Client

trait CompileReport { def items: List[CompileReportItem] } trait CompileReportItem { def target: BuildTargetIdentifier def errors: Long def warnings: Long def time: Option[Long] def linesOfCode: Option[Long] }

slide-29
SLIDE 29

29

buildTarget/test buildTarget/test

Client => Server

trait TestParams { def targets: List[BuildTargetIdentifier] def arguments: List[Json] }

Server => Client

trait TestReport { def items: List[TestReportItem] } trait TestReportItem { def target: BuildTargetIdentifier def compileReport: Option[CompileReportItem] def passed: Long def failed: Long def ignored: Long def time: Option[Long] }

slide-30
SLIDE 30

30

Other BSP methods Other BSP methods

Not covered in this presentation, Not covered in this presentation, but present in the spec. but present in the spec. buildTarget/didChange buildTarget/dependencyResources buildTarget/textDocuments textDocument/buildTargets

slide-31
SLIDE 31

31

So... is BSP language agnostic? So... is BSP language agnostic?

Yes! Yes!

slide-32
SLIDE 32

32

Scala extension BSP Core Java extension Rust extension Javascript extension ...

Meet language extensions Meet language extensions

Extensions formalize language-specific metadata, like: Extensions formalize language-specific metadata, like: Which standard library to use. Which platform a language runs on. Which compilation ags are enabled.

slide-33
SLIDE 33

33

Scala extension Scala extension

trait ScalaBuildTarget { def scalaOrganization: String def scalaCompiler: String def scalaVersion: String def scalaBinaryVersion: String def platform: ScalaPlatform }

  • bject ScalaPlatform {

val JVM = 1 val JS = 2 val Native = 3 }

slide-34
SLIDE 34

34

buildTarget/scalacOptions buildTarget/scalacOptions

Client => Server

trait ScalacOptionsParams { def targets: List[BuildTargetIdentifier] }

Server => Client

trait ScalacOptionsResult { def items: List[ScalcOptionItem] } trait ScalacOptionsItem { def target: BuildTargetIdentifier def options: List[String] def classpath: List[String] def classDirectory: String }

slide-35
SLIDE 35

35

buildTarget/scalaTestClasses buildTarget/scalaTestClasses

Client => Server

trait ScalaTestClassesParams { def targets: List[BuildTargetIdentifier] }

Server => Client

trait ScalaTestClassesResult { def items: List[ScalaTestClassesItem] } trait ScalaTestClassesItem { def target: BuildTargetIdentifier def classes: List[String] }

slide-36
SLIDE 36

36

On the roadmap On the roadmap

Add BSP method for le watching. Add compile progress notications. Add BSP buildTarget/run. Enable remote compilation. How do we handle repository state? Pass in diffs like LSP does. Relay repo synchronization to third-party.

slide-37
SLIDE 37

37

On the roadmap On the roadmap

On the lookout for feedback Formal proposal to STP-WG Scala/Scala.js-based client integrations: vim vscode sublime/atom scalacenter/bsp

slide-38
SLIDE 38

38

IntelliJ integration IntelliJ integration

slide-39
SLIDE 39

39

Thanks. Thanks.

Do you want to learn more? Come talk to us! Help improve the spec in scalacenter/bsp Chat on Bloop's Gitter. Chat on intellij-scala's Gitter.