SlideShare una empresa de Scribd logo
1 de 56
Descargar para leer sin conexión
sbt core concepts
Eugene Yokota (@eed3si9n)

Lightbend
goal:

gain better intuition about sbt
sbt に対する直感を育む
sbt by example


build tool
• "automates repeatable tasks"

— Build Systems à la Carte

Mokhov, Mitchell, Jones
「リピータブルなタスクの自動化」
a casually functional

build tool
カジュアルに関数型なビルドツール
State
State
1. build structure
2. your disk
sbt での状態は、ビルド構造とあなたのディスク
Command
• State State
Command
• State State
• processed sequentially
• low-level construct; avoid making custom commands
逐次処理される
低レベルなものなので、カスタムコマンドは避ける
examples of command
commands
help, tasks
projects, project hello
set name := "foo"
<command1>; <command2>
++ 2.13.0, ++ 2.13.0!, +<command>
shell command
act command
act command
• lifts tasks and settings into a command
act コマンドはタスクやセッティングを持ち上げる
which state is it changing?
commands changes
help, tasks no changes
projects, project hello build structure
set name := "foo" build structure
<command1>; <command2> both
++ 2.13.0, ++ 2.13.0!, +<command> both
act command disk
変更している状態はどっち?
why State + Command?
何のために State + Command があるの?
why State + Command?
• predictable checkpoint
• building block for interactiveness:

"automates repeatable tasks"
予測可能なチェックポイント
インタラクティブ性のための構成要素
interactive
sbt> testOnly foo.bar
command
logs
sbt shell
effects
about time
distributed events
event a
event b
"happens before"
process p
分散イベント
同プロセス内では、イベントの順序は自明
distributed events
event a
event b
"happens before"
process p process q
メッセージの送信はメッセージの受信よりも先にある
distributed events
• a → b (a happens before b)
• a ↛ b (a does not happen before b)
• 2 distinct events a and b are said to
be concurrent if a ↛ b and b ↛ a
a ↛ b かつ b ↛ a であるとき、2つのイベントは並行
distributed events
• a → b (a happens before b)
• a ↛ b (a does not happen before b)
• 2 distinct events a and b are said to
be concurrent if a ↛ b and b ↛ a
2 events are concurrent if neither can causality affect
each other
2つのイベントがお互いに因果的に影響を持たない場合、並行
Applicative functor
scala> (3.some, 2.some) mapN { _ + _ }
res8: Option[Int] = Some(5)
scala> (none[Int], 5.some) mapN { _ - _ }
res9: Option[Int] = None
See 'Oh, All the things you'll traverse' by Luka Jacobowitz
for comprehension
getLine flatMap { x =>
print(length(x)) flatMap { _ =>
getLine flatMap { y =>
IO(x ++ y)
}
}
}
for {
x <- getLine
_ <- print(length(x))
y <- getLine
} yield x ++ y
def procedural: Unit = {
val x = getLine
print(length(x))
val y = getLine
x ++ y
}
for 内包表記

build.sbt DSL
// sbt 0.12 style
foo <<= (compile in Compile, bar) map { (c, b) =>
doSomething(b)
}
// sbt 1.x style
foo := {
val c = (Compile / compile).value
val b = bar.value
doSomething(b)
}
build.sbt DSL
// sbt 0.12 style
foo <<= (compile in Compile, bar) map { (c, b) =>
doSomething(b)
}
// sbt 1.x style
foo := {
val c = (Compile / compile).value
val b = bar.value
doSomething(b)
}
Applicative composition
build.sbt DSL
foo := {
val c = (Compile / compile).value
val b = bar.value
doSomething(b)
}
Compile / compile bar
foo
"happens before"
build.sbt DSL
foo := {
val c = (Compile / compile).value
val b = bar.value
doSomething(b)
}
Compile / compile bar
foo
"happens before"
line of sand in time-space
Applicative composition
foo := {
val c = (Compile / compile).value
val b = bar.value
doSomething(b)
}
Test / test := {
val c = (Compile / compile).value
val f = foo.value
}
Compile / compile bar
foo
"happens before"
Test / test
"happens before"
why Applicative composition?
Compile / compile bar
foo
"happens before"
Test / test
"happens before"
何故 Applicative 合成をするのか?
why Applicative composition?
Compile / compile bar
foo
"happens before"
Test / test
"happens before"
1. minimality (executes task at most once, for input
that changed)
evaluated only once
ミニマル性 (タスクは入力が変化したとき、最多で1回のみ)
Compile / compile は一回のみ実行される
why Applicative composition?
Compile / compile bar
foo
"happens before"
Test / test
"happens before"
1. minimality
2. automatic parallel processing
自動並列処理

act command
• given a task, creates a plan that evaluates the task
in current and aggregated subprojects
• concurrent tasks are evaluated in parallel
lazy val root = (project in file("."))
.aggregate(util, core)
.settings(...)
lazy val util = (project in file("util"))
.dependsOn(core)
lazy val core = (project in file("core"))
act コマンドは、与えられたタスクを現在サブプロジェクトと

集約されたサブプロジェクトで実行するプランを作成する
act command
• how does it relate with State?
s0 s1 s2
reload (settings) act (task) act (task)
状態との関連は?

tasks vs commands
• prefer tasks for plugin extension
• tasks compose automatically
• command composition is stateful / sequential
プラグイン拡張性にはタスクがオススメ

タスクは自動合成するが、コマンド合成は stateful
~ command
build structure
ビルド構造

build structure: build
build {uri}
subproject {uri}foo
configuration foo/Compile
key-value store (settings + tasks)
Scala version
subproject {uri}bar
configuration bar/Compile
Scala version
build structure: subproject
build {uri}
subproject {uri}foo
configuration
foo/Compile
foo/Runtime
foo/Test
key-value store (settings + tasks)
Scala version
build structure: configuration
• has its own sources + library dependencies
• Test extends Runtime. Runtime extends
Compile.
subproject {uri}foo
configuration
foo/Compile
foo/Runtime
foo/Test
Scala version
コンフィギュレーションは独自のソースとライブラリ依存性を
持つ
build structure: k-v store
build {uri}
subproject {uri}foo
configuration foo/Compile
key-value store (settings + tasks)
Scala version
subproject {uri}bar
configuration bar/Compile
Scala version
key-value store
key value
name helloworld
version 0.1.0
organization com.example
key-value store
key value
foo/name helloworld
ThisBuild/version 0.1.0
ThisBuild/organization com.example
foo/Compile/compile <task>
foo/Compile/console/scalacOptions List()
key scoping
1. subproject (Zero, ThisBuild, foo, etc.)
2. configuration (Zero, Compile, Test, etc.)
3. in-task (Zero, console, etc.)
foo/Compile/console/scalacOptions
キーのスコープ付け

key-value store
key value
name
foo/name
foo/Zero/Zero/name helloworld
foo/Compile/console/scalacOptions List()
• keys are automatically scoped to the current subproject
• other scope axes default to Zero
• Global = Zero/Zero/Zero
キーは自動的にカレント・サブプロジェクトにスコープされる
他のスコープ軸のデフォルトは Zero
why key-value store?
• inspect command
• provides flexible extensibility on most aspects of the build
• plugins can created based on other plugins
sbt:sbtRoot> inspect tree test
[info] Test / test = Task[Unit]
[info] +-Test / executeTests = Task[sbt.Tests$Output]
[info] | +-classLoaderLayeringStrategy = ScalaLibrary
[info] | +-Test / loadedTestFrameworks = Task[scala.collection.immutable.Map[sbt.TestFramework, ..
[info] | | +-Test / loadedTestFrameworks / streams = Task[sbt.std.TaskStreams[sbt.internal.util...
[info] | | | +-Global / streamsManager = Task[sbt.std.Streams[sbt.internal.util.Init$..
[info] | | |
構造を inspect することができる
ビルドを形成する多くの部分を柔軟に拡張できる
setting expresion
name := { "hello" }
key operator (setting/task) body
• operators :=, +=, ++=
• a setting expression represents a transformation of
k-v store
セッティング式
setting expresion
ThisBuild / organization := "com.example"
name := (ThisBuild / organization).value + "12"
• use .value to lookup the setting/task value
• key-value store forms a DAG (directed acyclic
graph)
.value を使ってセッティングやタスクの値を参照する
key-value ストアは DAG を形成する
delegation rules
x := (core / Test / console / scalacOption).value
1. look for the specified key, then try in-task ⇢ Zero
2. next try Test ⇢ Runtime ⇢ Compile ⇢ Zero
3. next try core ⇢ ThisBuild ⇢ Zero
4. precedence: subproject > configuration > in-task
5. transitive evaluation doesn't carry original context (no
dynamic dispatch)
5つの移譲ルールがあり、指定されたキーが無い場合に
次に見る場所を規定する
delegation rules
ThisBuild / version := name.value
lazy val b = project
.settings(
name := "b"
something := version.value
)
• transitive evaluation doesn't carry original context
(no dynamic dispatch)
間接的評価は元のコンテキストを伴わない
OO の this.draw 的な振る舞いでは無い
tip for plugin authors
• define custom keys at the widest scope (Global),
and reference the keys using the narrowest scope
Global / obfuscateLogic := Logic.Default
Compile / obfuscate := {
val logic = (Compile / obfuscateLogic).value
doObfuscate(logic)
}
• This allows build users various levels to rewire the
setting (Global, ThisBuild, proj, proj/Compile)
カスタムキーは最も広いスコープ付けで定義し、
最も狭いスコープ付けで参照すると最大の柔軟性を得られる
key-value store
foo/Compile/scalacOptions
foo/name
ThisBuild/version
Test
Runtime
Compile
foo/Compile/compile
foo
ThisBuild
Zero
key
configuration
subproject
foo/Runtime/compile
foo/Test/compile
in-task
foo/Compile/console/scalacOptions
foo/baseDirectory
sbt 1.3.0
sbt 1.3.0 RC-2
• Coursier for library management
• super shell and tracing
• turbo mode (enabled layered ClassLoader)
• details https://www.lightbend.com/blog/sbt-1.3.0-
release
Coursier がライブラリ管理のデフォルト

super shell は現行タスクを表示させる
Thank You
delta vee (2019.06 mixtape)

Más contenido relacionado

La actualidad más candente

Gearman jobqueue
Gearman jobqueueGearman jobqueue
Gearman jobqueueMagento Dev
 
Infinispan,Lucene,Hibername OGM
Infinispan,Lucene,Hibername OGMInfinispan,Lucene,Hibername OGM
Infinispan,Lucene,Hibername OGMJBug Italy
 
Advanced task management with Celery
Advanced task management with CeleryAdvanced task management with Celery
Advanced task management with CeleryMahendra M
 
The Ring programming language version 1.2 book - Part 17 of 84
The Ring programming language version 1.2 book - Part 17 of 84The Ring programming language version 1.2 book - Part 17 of 84
The Ring programming language version 1.2 book - Part 17 of 84Mahmoud Samir Fayed
 
SenchaCon 2016: Modernizing the Ext JS Class System - Don Griffin
SenchaCon 2016: Modernizing the Ext JS Class System - Don GriffinSenchaCon 2016: Modernizing the Ext JS Class System - Don Griffin
SenchaCon 2016: Modernizing the Ext JS Class System - Don GriffinSencha
 
Aplicações assíncronas no Android com
Coroutines & Jetpack
Aplicações assíncronas no Android com
Coroutines & JetpackAplicações assíncronas no Android com
Coroutines & Jetpack
Aplicações assíncronas no Android com
Coroutines & JetpackNelson Glauber Leal
 
Utilizing Powerful Extensions for Analytics and Operations
Utilizing Powerful Extensions for Analytics and OperationsUtilizing Powerful Extensions for Analytics and Operations
Utilizing Powerful Extensions for Analytics and OperationsNeo4j
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot CampTroy Miles
 
Mastering Kotlin Standard Library
Mastering Kotlin Standard LibraryMastering Kotlin Standard Library
Mastering Kotlin Standard LibraryNelson Glauber Leal
 
Celery - A Distributed Task Queue
Celery - A Distributed Task QueueCelery - A Distributed Task Queue
Celery - A Distributed Task QueueDuy Do
 
Kotlin @ Coupang Backend 2017
Kotlin @ Coupang Backend 2017Kotlin @ Coupang Backend 2017
Kotlin @ Coupang Backend 2017Sunghyouk Bae
 
Alternatives of JPA/Hibernate
Alternatives of JPA/HibernateAlternatives of JPA/Hibernate
Alternatives of JPA/HibernateSunghyouk Bae
 
Beyond Map/Reduce: Getting Creative With Parallel Processing
Beyond Map/Reduce: Getting Creative With Parallel ProcessingBeyond Map/Reduce: Getting Creative With Parallel Processing
Beyond Map/Reduce: Getting Creative With Parallel ProcessingEd Kohlwey
 
Building High Perf Web Apps - IE8 Firestarter
Building High Perf Web Apps - IE8 FirestarterBuilding High Perf Web Apps - IE8 Firestarter
Building High Perf Web Apps - IE8 FirestarterMithun T. Dhar
 
Google App Engine Developer - Day3
Google App Engine Developer - Day3Google App Engine Developer - Day3
Google App Engine Developer - Day3Simon Su
 
No JS and DartCon
No JS and DartConNo JS and DartCon
No JS and DartConanandvns
 

La actualidad más candente (19)

Gearman jobqueue
Gearman jobqueueGearman jobqueue
Gearman jobqueue
 
Infinispan,Lucene,Hibername OGM
Infinispan,Lucene,Hibername OGMInfinispan,Lucene,Hibername OGM
Infinispan,Lucene,Hibername OGM
 
Advanced task management with Celery
Advanced task management with CeleryAdvanced task management with Celery
Advanced task management with Celery
 
The Ring programming language version 1.2 book - Part 17 of 84
The Ring programming language version 1.2 book - Part 17 of 84The Ring programming language version 1.2 book - Part 17 of 84
The Ring programming language version 1.2 book - Part 17 of 84
 
SenchaCon 2016: Modernizing the Ext JS Class System - Don Griffin
SenchaCon 2016: Modernizing the Ext JS Class System - Don GriffinSenchaCon 2016: Modernizing the Ext JS Class System - Don Griffin
SenchaCon 2016: Modernizing the Ext JS Class System - Don Griffin
 
Aplicações assíncronas no Android com
Coroutines & Jetpack
Aplicações assíncronas no Android com
Coroutines & JetpackAplicações assíncronas no Android com
Coroutines & Jetpack
Aplicações assíncronas no Android com
Coroutines & Jetpack
 
Utilizing Powerful Extensions for Analytics and Operations
Utilizing Powerful Extensions for Analytics and OperationsUtilizing Powerful Extensions for Analytics and Operations
Utilizing Powerful Extensions for Analytics and Operations
 
Requery overview
Requery overviewRequery overview
Requery overview
 
java
javajava
java
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot Camp
 
Mastering Kotlin Standard Library
Mastering Kotlin Standard LibraryMastering Kotlin Standard Library
Mastering Kotlin Standard Library
 
Spring data requery
Spring data requerySpring data requery
Spring data requery
 
Celery - A Distributed Task Queue
Celery - A Distributed Task QueueCelery - A Distributed Task Queue
Celery - A Distributed Task Queue
 
Kotlin @ Coupang Backend 2017
Kotlin @ Coupang Backend 2017Kotlin @ Coupang Backend 2017
Kotlin @ Coupang Backend 2017
 
Alternatives of JPA/Hibernate
Alternatives of JPA/HibernateAlternatives of JPA/Hibernate
Alternatives of JPA/Hibernate
 
Beyond Map/Reduce: Getting Creative With Parallel Processing
Beyond Map/Reduce: Getting Creative With Parallel ProcessingBeyond Map/Reduce: Getting Creative With Parallel Processing
Beyond Map/Reduce: Getting Creative With Parallel Processing
 
Building High Perf Web Apps - IE8 Firestarter
Building High Perf Web Apps - IE8 FirestarterBuilding High Perf Web Apps - IE8 Firestarter
Building High Perf Web Apps - IE8 Firestarter
 
Google App Engine Developer - Day3
Google App Engine Developer - Day3Google App Engine Developer - Day3
Google App Engine Developer - Day3
 
No JS and DartCon
No JS and DartConNo JS and DartCon
No JS and DartCon
 

Similar a sbt core concepts (ScalaMatsuri 2019)

Sbt職人のススメ
Sbt職人のススメSbt職人のススメ
Sbt職人のススメ潤一 加藤
 
Writing Redis in Python with asyncio
Writing Redis in Python with asyncioWriting Redis in Python with asyncio
Writing Redis in Python with asyncioJames Saryerwinnie
 
Django Celery - A distributed task queue
Django Celery - A distributed task queueDjango Celery - A distributed task queue
Django Celery - A distributed task queueAlex Eftimie
 
WebCamp 2016: DevOps. Ярослав Погребняк: Gobetween - новый лоад балансер для ...
WebCamp 2016: DevOps. Ярослав Погребняк: Gobetween - новый лоад балансер для ...WebCamp 2016: DevOps. Ярослав Погребняк: Gobetween - новый лоад балансер для ...
WebCamp 2016: DevOps. Ярослав Погребняк: Gobetween - новый лоад балансер для ...WebCamp
 
Full-Stack JavaScript with Node.js
Full-Stack JavaScript with Node.jsFull-Stack JavaScript with Node.js
Full-Stack JavaScript with Node.jsMichael Lehmann
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenerytoddbr
 
Declarative UI on iOS without SwiftUI (中文)
Declarative UI on iOS without SwiftUI (中文)Declarative UI on iOS without SwiftUI (中文)
Declarative UI on iOS without SwiftUI (中文)Shih-Ting Huang
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e bigAndy Peterson
 
Embulk - 進化するバルクデータローダ
Embulk - 進化するバルクデータローダEmbulk - 進化するバルクデータローダ
Embulk - 進化するバルクデータローダSadayuki Furuhashi
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing UpDavid Padbury
 
Evolutionary Database Design
Evolutionary Database DesignEvolutionary Database Design
Evolutionary Database DesignAndrei Solntsev
 
2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung Mosbach2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung MosbachJohannes Hoppe
 
Write Faster SQL with Trino.pdf
Write Faster SQL with Trino.pdfWrite Faster SQL with Trino.pdf
Write Faster SQL with Trino.pdfEric Xiao
 
You Might Just be a Functional Programmer Now
You Might Just be a Functional Programmer NowYou Might Just be a Functional Programmer Now
You Might Just be a Functional Programmer Nowcornelia davis
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbtFabio Fumarola
 

Similar a sbt core concepts (ScalaMatsuri 2019) (20)

Sbt職人のススメ
Sbt職人のススメSbt職人のススメ
Sbt職人のススメ
 
Writing Redis in Python with asyncio
Writing Redis in Python with asyncioWriting Redis in Python with asyncio
Writing Redis in Python with asyncio
 
Django Celery - A distributed task queue
Django Celery - A distributed task queueDjango Celery - A distributed task queue
Django Celery - A distributed task queue
 
WebCamp 2016: DevOps. Ярослав Погребняк: Gobetween - новый лоад балансер для ...
WebCamp 2016: DevOps. Ярослав Погребняк: Gobetween - новый лоад балансер для ...WebCamp 2016: DevOps. Ярослав Погребняк: Gobetween - новый лоад балансер для ...
WebCamp 2016: DevOps. Ярослав Погребняк: Gobetween - новый лоад балансер для ...
 
Full-Stack JavaScript with Node.js
Full-Stack JavaScript with Node.jsFull-Stack JavaScript with Node.js
Full-Stack JavaScript with Node.js
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
 
Declarative UI on iOS without SwiftUI (中文)
Declarative UI on iOS without SwiftUI (中文)Declarative UI on iOS without SwiftUI (中文)
Declarative UI on iOS without SwiftUI (中文)
 
Play framework
Play frameworkPlay framework
Play framework
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
 
Embuk internals
Embuk internalsEmbuk internals
Embuk internals
 
Clojure And Swing
Clojure And SwingClojure And Swing
Clojure And Swing
 
Embulk - 進化するバルクデータローダ
Embulk - 進化するバルクデータローダEmbulk - 進化するバルクデータローダ
Embulk - 進化するバルクデータローダ
 
Slickdemo
SlickdemoSlickdemo
Slickdemo
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
Evolutionary Database Design
Evolutionary Database DesignEvolutionary Database Design
Evolutionary Database Design
 
2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung Mosbach2015 02-09 - NoSQL Vorlesung Mosbach
2015 02-09 - NoSQL Vorlesung Mosbach
 
Couchbas for dummies
Couchbas for dummiesCouchbas for dummies
Couchbas for dummies
 
Write Faster SQL with Trino.pdf
Write Faster SQL with Trino.pdfWrite Faster SQL with Trino.pdf
Write Faster SQL with Trino.pdf
 
You Might Just be a Functional Programmer Now
You Might Just be a Functional Programmer NowYou Might Just be a Functional Programmer Now
You Might Just be a Functional Programmer Now
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbt
 

Más de Eugene Yokota

Equality in Scala (ScalaMatsuri 2020)
Equality in Scala (ScalaMatsuri 2020)Equality in Scala (ScalaMatsuri 2020)
Equality in Scala (ScalaMatsuri 2020)Eugene Yokota
 
Analysis of Zinc (nescala 2020)
Analysis of Zinc (nescala 2020)Analysis of Zinc (nescala 2020)
Analysis of Zinc (nescala 2020)Eugene Yokota
 
Analysis of Zinc (ScalaSphere 2019)
Analysis of Zinc (ScalaSphere 2019)Analysis of Zinc (ScalaSphere 2019)
Analysis of Zinc (ScalaSphere 2019)Eugene Yokota
 
pull requests I sent to scala/scala (ny-scala 2019)
pull requests I sent to scala/scala (ny-scala 2019)pull requests I sent to scala/scala (ny-scala 2019)
pull requests I sent to scala/scala (ny-scala 2019)Eugene Yokota
 
sbt server (LSP discussion, 2018 Jan)
sbt server (LSP discussion, 2018 Jan)sbt server (LSP discussion, 2018 Jan)
sbt server (LSP discussion, 2018 Jan)Eugene Yokota
 
sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)
sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)
sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)Eugene Yokota
 
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaSphere ver)
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaSphere ver)The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaSphere ver)
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaSphere ver)Eugene Yokota
 
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaMatsuri ver)
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaMatsuri ver)The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaMatsuri ver)
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaMatsuri ver)Eugene Yokota
 
Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)Eugene Yokota
 
Road to sbt 1.0 paved with server
Road to sbt 1.0   paved with serverRoad to sbt 1.0   paved with server
Road to sbt 1.0 paved with serverEugene Yokota
 

Más de Eugene Yokota (12)

Equality in Scala (ScalaMatsuri 2020)
Equality in Scala (ScalaMatsuri 2020)Equality in Scala (ScalaMatsuri 2020)
Equality in Scala (ScalaMatsuri 2020)
 
Analysis of Zinc (nescala 2020)
Analysis of Zinc (nescala 2020)Analysis of Zinc (nescala 2020)
Analysis of Zinc (nescala 2020)
 
Analysis of Zinc (ScalaSphere 2019)
Analysis of Zinc (ScalaSphere 2019)Analysis of Zinc (ScalaSphere 2019)
Analysis of Zinc (ScalaSphere 2019)
 
pull requests I sent to scala/scala (ny-scala 2019)
pull requests I sent to scala/scala (ny-scala 2019)pull requests I sent to scala/scala (ny-scala 2019)
pull requests I sent to scala/scala (ny-scala 2019)
 
sbt 1
sbt 1sbt 1
sbt 1
 
sbt server (LSP discussion, 2018 Jan)
sbt server (LSP discussion, 2018 Jan)sbt server (LSP discussion, 2018 Jan)
sbt server (LSP discussion, 2018 Jan)
 
sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)
sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)
sbt, history of JSON libraries, microservices, and schema evolution (Tokyo ver)
 
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaSphere ver)
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaSphere ver)The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaSphere ver)
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaSphere ver)
 
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaMatsuri ver)
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaMatsuri ver)The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaMatsuri ver)
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaMatsuri ver)
 
Thinking in Cats
Thinking in CatsThinking in Cats
Thinking in Cats
 
Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)
 
Road to sbt 1.0 paved with server
Road to sbt 1.0   paved with serverRoad to sbt 1.0   paved with server
Road to sbt 1.0 paved with server
 

Último

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 

Último (20)

Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 

sbt core concepts (ScalaMatsuri 2019)

  • 1. sbt core concepts Eugene Yokota (@eed3si9n)
 Lightbend
  • 2. goal: gain better intuition about sbt sbt に対する直感を育む
  • 4. 
 build tool • "automates repeatable tasks"
 — Build Systems à la Carte
 Mokhov, Mitchell, Jones 「リピータブルなタスクの自動化」
  • 5. a casually functional
 build tool カジュアルに関数型なビルドツール
  • 7. State 1. build structure 2. your disk sbt での状態は、ビルド構造とあなたのディスク
  • 9. Command • State State • processed sequentially • low-level construct; avoid making custom commands 逐次処理される 低レベルなものなので、カスタムコマンドは避ける
  • 10. examples of command commands help, tasks projects, project hello set name := "foo" <command1>; <command2> ++ 2.13.0, ++ 2.13.0!, +<command> shell command act command
  • 11. act command • lifts tasks and settings into a command act コマンドはタスクやセッティングを持ち上げる
  • 12. which state is it changing? commands changes help, tasks no changes projects, project hello build structure set name := "foo" build structure <command1>; <command2> both ++ 2.13.0, ++ 2.13.0!, +<command> both act command disk 変更している状態はどっち?
  • 13. why State + Command? 何のために State + Command があるの?
  • 14. why State + Command? • predictable checkpoint • building block for interactiveness:
 "automates repeatable tasks" 予測可能なチェックポイント インタラクティブ性のための構成要素
  • 17.
  • 18.
  • 19. distributed events event a event b "happens before" process p 分散イベント 同プロセス内では、イベントの順序は自明
  • 20. distributed events event a event b "happens before" process p process q メッセージの送信はメッセージの受信よりも先にある
  • 21. distributed events • a → b (a happens before b) • a ↛ b (a does not happen before b) • 2 distinct events a and b are said to be concurrent if a ↛ b and b ↛ a a ↛ b かつ b ↛ a であるとき、2つのイベントは並行
  • 22. distributed events • a → b (a happens before b) • a ↛ b (a does not happen before b) • 2 distinct events a and b are said to be concurrent if a ↛ b and b ↛ a 2 events are concurrent if neither can causality affect each other 2つのイベントがお互いに因果的に影響を持たない場合、並行
  • 23. Applicative functor scala> (3.some, 2.some) mapN { _ + _ } res8: Option[Int] = Some(5) scala> (none[Int], 5.some) mapN { _ - _ } res9: Option[Int] = None See 'Oh, All the things you'll traverse' by Luka Jacobowitz
  • 24. for comprehension getLine flatMap { x => print(length(x)) flatMap { _ => getLine flatMap { y => IO(x ++ y) } } } for { x <- getLine _ <- print(length(x)) y <- getLine } yield x ++ y def procedural: Unit = { val x = getLine print(length(x)) val y = getLine x ++ y } for 内包表記

  • 25. build.sbt DSL // sbt 0.12 style foo <<= (compile in Compile, bar) map { (c, b) => doSomething(b) } // sbt 1.x style foo := { val c = (Compile / compile).value val b = bar.value doSomething(b) }
  • 26. build.sbt DSL // sbt 0.12 style foo <<= (compile in Compile, bar) map { (c, b) => doSomething(b) } // sbt 1.x style foo := { val c = (Compile / compile).value val b = bar.value doSomething(b) } Applicative composition
  • 27. build.sbt DSL foo := { val c = (Compile / compile).value val b = bar.value doSomething(b) } Compile / compile bar foo "happens before"
  • 28. build.sbt DSL foo := { val c = (Compile / compile).value val b = bar.value doSomething(b) } Compile / compile bar foo "happens before" line of sand in time-space
  • 29. Applicative composition foo := { val c = (Compile / compile).value val b = bar.value doSomething(b) } Test / test := { val c = (Compile / compile).value val f = foo.value } Compile / compile bar foo "happens before" Test / test "happens before"
  • 30. why Applicative composition? Compile / compile bar foo "happens before" Test / test "happens before" 何故 Applicative 合成をするのか?
  • 31. why Applicative composition? Compile / compile bar foo "happens before" Test / test "happens before" 1. minimality (executes task at most once, for input that changed) evaluated only once ミニマル性 (タスクは入力が変化したとき、最多で1回のみ) Compile / compile は一回のみ実行される
  • 32. why Applicative composition? Compile / compile bar foo "happens before" Test / test "happens before" 1. minimality 2. automatic parallel processing 自動並列処理

  • 33. act command • given a task, creates a plan that evaluates the task in current and aggregated subprojects • concurrent tasks are evaluated in parallel lazy val root = (project in file(".")) .aggregate(util, core) .settings(...) lazy val util = (project in file("util")) .dependsOn(core) lazy val core = (project in file("core")) act コマンドは、与えられたタスクを現在サブプロジェクトと
 集約されたサブプロジェクトで実行するプランを作成する
  • 34. act command • how does it relate with State? s0 s1 s2 reload (settings) act (task) act (task) 状態との関連は?

  • 35. tasks vs commands • prefer tasks for plugin extension • tasks compose automatically • command composition is stateful / sequential プラグイン拡張性にはタスクがオススメ
 タスクは自動合成するが、コマンド合成は stateful
  • 38. build structure: build build {uri} subproject {uri}foo configuration foo/Compile key-value store (settings + tasks) Scala version subproject {uri}bar configuration bar/Compile Scala version
  • 39. build structure: subproject build {uri} subproject {uri}foo configuration foo/Compile foo/Runtime foo/Test key-value store (settings + tasks) Scala version
  • 40. build structure: configuration • has its own sources + library dependencies • Test extends Runtime. Runtime extends Compile. subproject {uri}foo configuration foo/Compile foo/Runtime foo/Test Scala version コンフィギュレーションは独自のソースとライブラリ依存性を 持つ
  • 41. build structure: k-v store build {uri} subproject {uri}foo configuration foo/Compile key-value store (settings + tasks) Scala version subproject {uri}bar configuration bar/Compile Scala version
  • 42. key-value store key value name helloworld version 0.1.0 organization com.example
  • 43. key-value store key value foo/name helloworld ThisBuild/version 0.1.0 ThisBuild/organization com.example foo/Compile/compile <task> foo/Compile/console/scalacOptions List()
  • 44. key scoping 1. subproject (Zero, ThisBuild, foo, etc.) 2. configuration (Zero, Compile, Test, etc.) 3. in-task (Zero, console, etc.) foo/Compile/console/scalacOptions キーのスコープ付け

  • 45. key-value store key value name foo/name foo/Zero/Zero/name helloworld foo/Compile/console/scalacOptions List() • keys are automatically scoped to the current subproject • other scope axes default to Zero • Global = Zero/Zero/Zero キーは自動的にカレント・サブプロジェクトにスコープされる 他のスコープ軸のデフォルトは Zero
  • 46. why key-value store? • inspect command • provides flexible extensibility on most aspects of the build • plugins can created based on other plugins sbt:sbtRoot> inspect tree test [info] Test / test = Task[Unit] [info] +-Test / executeTests = Task[sbt.Tests$Output] [info] | +-classLoaderLayeringStrategy = ScalaLibrary [info] | +-Test / loadedTestFrameworks = Task[scala.collection.immutable.Map[sbt.TestFramework, .. [info] | | +-Test / loadedTestFrameworks / streams = Task[sbt.std.TaskStreams[sbt.internal.util... [info] | | | +-Global / streamsManager = Task[sbt.std.Streams[sbt.internal.util.Init$.. [info] | | | 構造を inspect することができる ビルドを形成する多くの部分を柔軟に拡張できる
  • 47. setting expresion name := { "hello" } key operator (setting/task) body • operators :=, +=, ++= • a setting expression represents a transformation of k-v store セッティング式
  • 48. setting expresion ThisBuild / organization := "com.example" name := (ThisBuild / organization).value + "12" • use .value to lookup the setting/task value • key-value store forms a DAG (directed acyclic graph) .value を使ってセッティングやタスクの値を参照する key-value ストアは DAG を形成する
  • 49. delegation rules x := (core / Test / console / scalacOption).value 1. look for the specified key, then try in-task ⇢ Zero 2. next try Test ⇢ Runtime ⇢ Compile ⇢ Zero 3. next try core ⇢ ThisBuild ⇢ Zero 4. precedence: subproject > configuration > in-task 5. transitive evaluation doesn't carry original context (no dynamic dispatch) 5つの移譲ルールがあり、指定されたキーが無い場合に 次に見る場所を規定する
  • 50. delegation rules ThisBuild / version := name.value lazy val b = project .settings( name := "b" something := version.value ) • transitive evaluation doesn't carry original context (no dynamic dispatch) 間接的評価は元のコンテキストを伴わない OO の this.draw 的な振る舞いでは無い
  • 51. tip for plugin authors • define custom keys at the widest scope (Global), and reference the keys using the narrowest scope Global / obfuscateLogic := Logic.Default Compile / obfuscate := { val logic = (Compile / obfuscateLogic).value doObfuscate(logic) } • This allows build users various levels to rewire the setting (Global, ThisBuild, proj, proj/Compile) カスタムキーは最も広いスコープ付けで定義し、 最も狭いスコープ付けで参照すると最大の柔軟性を得られる
  • 54. sbt 1.3.0 RC-2 • Coursier for library management • super shell and tracing • turbo mode (enabled layered ClassLoader) • details https://www.lightbend.com/blog/sbt-1.3.0- release Coursier がライブラリ管理のデフォルト
 super shell は現行タスクを表示させる
  • 56. delta vee (2019.06 mixtape)