sbt 1
Eugene Yokota (@eed3si9n)
Dale Wijnand (@dwijnand)

June 2018
• Lightbend Tooling team
who are these guys
Eugene
(@eed3si9n)
Dale
(@dwijnand)
• Lightbend Tooling team
sbt by example
• https://www.scala-sbt.org/1.x/docs/sbt-by-
example.html
overhaul
overhaul
overhaul
• remove old parts
• update new parts
• know-how of rebuilding the parts
goal of sbt 1
• minimize conceptual jump from sbt 0.13
sbt 1 (updated parts)
• Semantic Versioning
• Binary compatible throughout 1.y.z
• Feature releases and Patch releases
sbt 1 (updated parts)
• Use Maven Central
• As opposed to Ivy layout hosted on Bintray behind
redirect
sbt 1 (updated parts)
• Use Scala 2.12 for build definition
• As opposed to Scala 2.10
sbt 1 (updated parts)
• Pseudo-case classes generated by Contraband
• https://www.scala-sbt.org/contraband/
• Instead of .copy(foo = 1), you write .withFoo(1)
• Generates JSON codec
sbt 1 (updated parts)
• Incremental compiler Zinc 1
• https://github.com/sbt/zinc
• Class-based name hashing
sbt 1 (updated parts)
• Library Management (LM) API
• https://github.com/sbt/librarymanagement
• Abstracts Apache Ivy so we can replace it later
sbt 1 (removed parts)
• sbt.Plugin
• Use sbt.AutoPlugin introduced in sbt 0.13.5
sbt 1 (removed parts)
• sbt 0.12 style
• the key dependency operators: <<=, <+=, <++=
• the tuple enrichments (apply and map)
• sbt.Build trait in project/Build.scala
sbt 1 (new parts)
• sbt server
• unified slash syntax
• more on these later
sbt ecosystem
sbt is a hub
• builds
• dependency graph, library ecosystem
• test interface
• development tasks
• plugins
• developers (users & contributors)
how big is the ecosystem
• 147,367 code results
• "scalaVersion" extension:sbt
how big is the ecosystem
• 209,745 download per month (sbt 1 on Maven Central)
• (excludes preloaded .zip, .tgz, .msi)
how big is the ecosystem
• 12956 downloads (in 7 days after 1.1.5 came out)
how big is the ecosystem
• 455 plugins (341 0.13 plugins; 224 1.0 plugins)
• 600+ packages on Bintray sbt/sbt-plugin-releases
migrating the plugin ecosystem
• organizing community efforts
10 days later..
migrating the plugins ecosystem
• 99 plugins were on sbt 1 in 2 months
Places to find us
• sbt 1 / Zinc meeting (every Wednesday)
• Gitter (sbt/sbt + sbt/sbt-contrib)
• Lightbend Discuss: https://
discuss.lightbend.com/c/tooling
• Stackoverflow: http://stackoverflow.com/
tags/sbt
• GitHub Issues: sbt/sbt
• Twitter: https://twitter.com/scala_sbt
• and lots of repos...
GitHub repos
• sbt/sbt - the build tool
• sbt/zinc
• sbt/librarymanagement
• sbt/util
• sbt/io
• sbt/website
• sbt/launcher
• sbt/sbt-launcher-package
• sbt/contraband
• sbt/sbt-houserules
GitHub repos
• sbt/sbt - the build tool
• sbt/zinc
• sbt/librarymanagement
• sbt/util
• sbt/io
• sbt/website
• sbt/launcher
• sbt/sbt-launcher-package
• sbt/contraband
• sbt/sbt-houserules
all repos:
• build: sbt
• PR validation: Travis CI
• Testing: ScalaTest/Specs2/ScalaCheck/scripted
Types of contributions
• Help adoption
• Assist other users
• At work, on Stackoverflow etc
• Contribute to documentation
• Garden the issue tracker
• Report issues
• Expand ecosystem
• Patch the core
Gardening the issue tracker
• Summarize discussions from other channels
• Capture problems
• Sift facts, opinions, and analysis (steps, problems,
expectations, notes)
• Reproduce the reported issues
• Triage
• Leaving breadcrumbs for contributors (previous
discussions, source links)
Patching the core
• Lightbend Discuss
• "Help wanted", "Good first issue"
Plugins that got merged to sbt
• sbt-core-next
• sbt-doge
• sbt-slash
• sbt-cross-building
sbt server
• See http://eed3si9n.com/sbt-server-reboot
sbt server reboot
Language Server Protocol
• created by Microsoft for VS Code
• abstracts IDE features like a web API
LSP
VS Code
Eclipse
Sublime 3
NeoVim
TypeScript
Python
sbt
demand for rich development environment
• Jump to error
• Code navigation
• Tab completion
• Visual debugging
• Incremental compiler
• Library management
• Test integration
• Plugin capabilities
(100+ of plugins)
Editors sbt
• LSP
• Event logging
a brief history of sbt server
• 'client-server split for sbt' (2013) Havoc Pennington
• A proposal to split sbt into 2 JVMs: client (cmd,
IDE, Play run etc) talks to server.
• Typesafe Activator 1.3.0 (2015) was released
using sbt-remote-control.
• 'sbt server reboot' (2016) Eugene Yokota
• 1 JVM. sbt server listens to both CLI and
network. IDEA calling compile.
• sbt 1.1.0 (2017) was released with server built-in
using Language Server Protocol.
• single JVM process
• implemented as a command, sort of
• JSON API to drive sbt from network
what is sbt server?
• IDE integration
• Distributed build
example usages
sbt main loop
shell prompts the user
sbt new "shell" command
shell prompts the user, 

and listens to network
nc
$ nc -U /Users/foo/.sbt/1.0/server/
0845deda85cb41abcdef/sock
Content-Length: 99^M
^M
{ "jsonrpc": "2.0", "id": 1, "method":
"initialize", "params":
{ "initializationOptions": { } } }^M
...
input/output of common tasks
compile task
input/output of common tasks
• Outputs are side effects to disk and screen
event logging
• A way to log object (semantic logging)
• Logs are then relayed as JSON
• Decoupled from screens
unified slash syntax
sbt
• a way of describing your build
• interactive shell for development
sbt 0.13
• (scalacOptions in (Test, console)).value
• test:console::scalacOptions
sbt 1.1.x
• (Test/console/scalacOptions).value
• Test/console/scalacOptions
unified slash syntax
• [reference /] [Config /] [intask /] key
• foo / compile
• foo / Test / compile
• ThisBuild / organization
• foo / Compile / console / scalacOptions
scope delegation
• [reference /] [Config /] [intask /] key
• foo / Test / console / scalacOptions
Zero
Runtime console
Compile
Zero
Zero
ThisBuild
Zero
Zero
... ...
problematic areas
sauce dependency
sbt-sriracha
• adds .sourceDependency(scoptJVMRef,
scoptJVMLib)
• use -Dsbt.sourcemode=true to switch
http://eed3si9n.com/hot-source-dependencies-using-sbt-sriracha
lazy val scoptJVMRef = ProjectRef(
workspaceDirectory / "scopt", "scoptJVM")
lazy val scoptJVMLib = "com.github.scopt" %% "scopt" % "3.7.0"
 
lazy val root = (project in file("."))
.sourceDependency(scoptJVMRef, scoptJVMLib)
.settings(
name := "Hello world"
)
cross building across
Scala versions, platforms, etc
sbt-projectmatrix (TBA)
• adds lazy val foo = projectMatrix
lazy val core = (projectMatrix in file("core"))
.scalaVersions("2.12.6", "2.11.12")
.settings(
name := "core"
)
.jvmPlatform()
lazy val app = (projectMatrix in file("app"))
.dependsOn(core)
.scalaVersions("2.12.6")
.settings(
name := "app"
)
.jvmPlatform()
https://discuss.lightbend.com/t/spatial-representation-of-cross-
building/1277/9
Potential areas of contribution
• Library management (Coursier)
• Dependency locking
• Migrate code examples to compiled docs
• Look for "Help wanted" label in GitHub issues
Questions?
Lightbend Subscription

sbt 1

  • 1.
    sbt 1 Eugene Yokota(@eed3si9n) Dale Wijnand (@dwijnand)
 June 2018
  • 2.
    • Lightbend Toolingteam who are these guys Eugene (@eed3si9n) Dale (@dwijnand) • Lightbend Tooling team
  • 3.
    sbt by example •https://www.scala-sbt.org/1.x/docs/sbt-by- example.html
  • 4.
  • 5.
  • 6.
    overhaul • remove oldparts • update new parts • know-how of rebuilding the parts
  • 7.
    goal of sbt1 • minimize conceptual jump from sbt 0.13
  • 8.
    sbt 1 (updatedparts) • Semantic Versioning • Binary compatible throughout 1.y.z • Feature releases and Patch releases
  • 9.
    sbt 1 (updatedparts) • Use Maven Central • As opposed to Ivy layout hosted on Bintray behind redirect
  • 10.
    sbt 1 (updatedparts) • Use Scala 2.12 for build definition • As opposed to Scala 2.10
  • 11.
    sbt 1 (updatedparts) • Pseudo-case classes generated by Contraband • https://www.scala-sbt.org/contraband/ • Instead of .copy(foo = 1), you write .withFoo(1) • Generates JSON codec
  • 12.
    sbt 1 (updatedparts) • Incremental compiler Zinc 1 • https://github.com/sbt/zinc • Class-based name hashing
  • 13.
    sbt 1 (updatedparts) • Library Management (LM) API • https://github.com/sbt/librarymanagement • Abstracts Apache Ivy so we can replace it later
  • 14.
    sbt 1 (removedparts) • sbt.Plugin • Use sbt.AutoPlugin introduced in sbt 0.13.5
  • 15.
    sbt 1 (removedparts) • sbt 0.12 style • the key dependency operators: <<=, <+=, <++= • the tuple enrichments (apply and map) • sbt.Build trait in project/Build.scala
  • 16.
    sbt 1 (newparts) • sbt server • unified slash syntax • more on these later
  • 17.
  • 18.
    sbt is ahub • builds • dependency graph, library ecosystem • test interface • development tasks • plugins • developers (users & contributors)
  • 19.
    how big isthe ecosystem • 147,367 code results • "scalaVersion" extension:sbt
  • 20.
    how big isthe ecosystem • 209,745 download per month (sbt 1 on Maven Central) • (excludes preloaded .zip, .tgz, .msi)
  • 21.
    how big isthe ecosystem • 12956 downloads (in 7 days after 1.1.5 came out)
  • 22.
    how big isthe ecosystem • 455 plugins (341 0.13 plugins; 224 1.0 plugins) • 600+ packages on Bintray sbt/sbt-plugin-releases
  • 23.
    migrating the pluginecosystem • organizing community efforts 10 days later..
  • 24.
    migrating the pluginsecosystem • 99 plugins were on sbt 1 in 2 months
  • 25.
    Places to findus • sbt 1 / Zinc meeting (every Wednesday) • Gitter (sbt/sbt + sbt/sbt-contrib) • Lightbend Discuss: https:// discuss.lightbend.com/c/tooling • Stackoverflow: http://stackoverflow.com/ tags/sbt • GitHub Issues: sbt/sbt • Twitter: https://twitter.com/scala_sbt • and lots of repos...
  • 26.
    GitHub repos • sbt/sbt- the build tool • sbt/zinc • sbt/librarymanagement • sbt/util • sbt/io • sbt/website • sbt/launcher • sbt/sbt-launcher-package • sbt/contraband • sbt/sbt-houserules
  • 27.
    GitHub repos • sbt/sbt- the build tool • sbt/zinc • sbt/librarymanagement • sbt/util • sbt/io • sbt/website • sbt/launcher • sbt/sbt-launcher-package • sbt/contraband • sbt/sbt-houserules all repos: • build: sbt • PR validation: Travis CI • Testing: ScalaTest/Specs2/ScalaCheck/scripted
  • 28.
    Types of contributions •Help adoption • Assist other users • At work, on Stackoverflow etc • Contribute to documentation • Garden the issue tracker • Report issues • Expand ecosystem • Patch the core
  • 29.
    Gardening the issuetracker • Summarize discussions from other channels • Capture problems • Sift facts, opinions, and analysis (steps, problems, expectations, notes) • Reproduce the reported issues • Triage • Leaving breadcrumbs for contributors (previous discussions, source links)
  • 30.
    Patching the core •Lightbend Discuss • "Help wanted", "Good first issue"
  • 31.
    Plugins that gotmerged to sbt • sbt-core-next • sbt-doge • sbt-slash • sbt-cross-building
  • 32.
  • 33.
  • 34.
    Language Server Protocol •created by Microsoft for VS Code • abstracts IDE features like a web API LSP VS Code Eclipse Sublime 3 NeoVim TypeScript Python sbt
  • 35.
    demand for richdevelopment environment • Jump to error • Code navigation • Tab completion • Visual debugging • Incremental compiler • Library management • Test integration • Plugin capabilities (100+ of plugins) Editors sbt • LSP • Event logging
  • 36.
    a brief historyof sbt server • 'client-server split for sbt' (2013) Havoc Pennington • A proposal to split sbt into 2 JVMs: client (cmd, IDE, Play run etc) talks to server. • Typesafe Activator 1.3.0 (2015) was released using sbt-remote-control. • 'sbt server reboot' (2016) Eugene Yokota • 1 JVM. sbt server listens to both CLI and network. IDEA calling compile. • sbt 1.1.0 (2017) was released with server built-in using Language Server Protocol.
  • 37.
    • single JVMprocess • implemented as a command, sort of • JSON API to drive sbt from network what is sbt server?
  • 38.
    • IDE integration •Distributed build example usages
  • 39.
    sbt main loop shellprompts the user
  • 40.
    sbt new "shell"command shell prompts the user, 
 and listens to network
  • 41.
    nc $ nc -U/Users/foo/.sbt/1.0/server/ 0845deda85cb41abcdef/sock Content-Length: 99^M ^M { "jsonrpc": "2.0", "id": 1, "method": "initialize", "params": { "initializationOptions": { } } }^M ...
  • 42.
    input/output of commontasks compile task
  • 43.
    input/output of commontasks • Outputs are side effects to disk and screen
  • 44.
    event logging • Away to log object (semantic logging) • Logs are then relayed as JSON • Decoupled from screens
  • 45.
  • 46.
    sbt • a wayof describing your build • interactive shell for development
  • 47.
    sbt 0.13 • (scalacOptionsin (Test, console)).value • test:console::scalacOptions
  • 48.
  • 49.
    unified slash syntax •[reference /] [Config /] [intask /] key • foo / compile • foo / Test / compile • ThisBuild / organization • foo / Compile / console / scalacOptions
  • 50.
    scope delegation • [reference/] [Config /] [intask /] key • foo / Test / console / scalacOptions Zero Runtime console Compile Zero Zero ThisBuild Zero Zero ... ...
  • 51.
  • 52.
  • 53.
    sbt-sriracha • adds .sourceDependency(scoptJVMRef, scoptJVMLib) •use -Dsbt.sourcemode=true to switch http://eed3si9n.com/hot-source-dependencies-using-sbt-sriracha lazy val scoptJVMRef = ProjectRef( workspaceDirectory / "scopt", "scoptJVM") lazy val scoptJVMLib = "com.github.scopt" %% "scopt" % "3.7.0"   lazy val root = (project in file(".")) .sourceDependency(scoptJVMRef, scoptJVMLib) .settings( name := "Hello world" )
  • 54.
    cross building across Scalaversions, platforms, etc
  • 55.
    sbt-projectmatrix (TBA) • addslazy val foo = projectMatrix lazy val core = (projectMatrix in file("core")) .scalaVersions("2.12.6", "2.11.12") .settings( name := "core" ) .jvmPlatform() lazy val app = (projectMatrix in file("app")) .dependsOn(core) .scalaVersions("2.12.6") .settings( name := "app" ) .jvmPlatform() https://discuss.lightbend.com/t/spatial-representation-of-cross- building/1277/9
  • 56.
    Potential areas ofcontribution • Library management (Coursier) • Dependency locking • Migrate code examples to compiled docs • Look for "Help wanted" label in GitHub issues
  • 57.
  • 59.