SlideShare una empresa de Scribd logo
1 de 30
Descargar para leer sin conexión
SBT CRASH COURSEBy /Michal Bigos @teliatko
SBT CRASH COURSE
1. Why SBT
2. How SBT works
3. Example of simple project
4. Core concepts
WHY SBT
GOOD BUILD TOOL CRITERIA
Reproducibility - automating build, gives you more time to
do real stuff
Conventions - using sensible defaults, no need to specify
every last option and command
Experience - distilation of developer wisdom, e.g. test
before publish
Portability - good build tool should protect you from
differences betweeen systems
Ecosystem - allow to extend build easily
WHY SBT
LITTLE HISTORY: APACHE ANT
Former standard build tool for Java projects
Pros:
1. Portability - build is defined in XML by chaining tasks
2. Experience - abillity to explicitly define dependencies
between tasks
Cons:
1. Conventions - no default build lifecycle, each build is
piece of art
2. Ecosystem - not easy to extend, task definition
distributed as jar
WHY SBT
LITTLE HISTORY: APACHE MAVEN
Currently heavily used in enterprise Java projects
Most opinionated build tool
Pros:
1. Portability - build is defined in XML so called POM
2. Experience, Conventions - Maven introduces default
lifecycle with its phases and tasks. It promotes
declarative dependency management.
Cons:
1. Ecosystem - not easy to extend. Maven plug-in
archtecrure requires plug-in written in Java, then POMs
and packaging and availability in repository.
WHY SBT
LITTLE HISTORY: GOOD PARTS
Default project layout (Maven)
Default project behavior (Maven)
Declarative dependency management (Maven)
Portability (Ant, Maven)
WHY SBT
FEATURES AT GLACE
Uses Scala to describe build
Can be used for Java and Scala
Minimal configuration (inspired by Maven)
A number of build-in tasks
Declarative dependency management (using Apache Ivy)
Portability
Reactive development environment
Allows use Scala REPL
Incremental compilation
Automatic re-compilation with different versions of Scala
HOW SBT WORKS
TASKS
Task based, more like ANT, no phases like in Maven
If you want to do something you execute a task
If you want to ensure that a task runs after another, add an
explicit dependency between the tasks
Output of a task is value, which can be of any type and past
to any another task
Multiple tasks can depend upon the output of the same
task
By default tasks are executed in parallel
Using dependency tree sbt can work out what can be run in
parallel or in sequence
HOW SBT WORKS
DEFAULT STRUCTURE AND LAYOUT
Inspired by Maven
{project root}
project/
build.properties
plugins.sbt
src/
main/
scala/
java/
resources/
test/
scala/
java/
resources/
target/
build.sbt
HOW SBT WORKS
TASKS 'VS PLUGINS
Appear directly in build definition file, shared via VCS
Task can be turned into plugin and shared via repository
val gitHeadCommitSHA = taskKey[String]("Determines the current git comm
it SHA")
gitHeadComitSHA := Process("git rev-parse HEAD").lines.head
HOW SBT WORKS
PHASES 'VS TASK DEPENDENCIES
In Maven, the order of execution tasks in phases always
leads to confusion
Default goals for a phase are executed before explicitly
defined and those are executed in implicit order of
definition in POM file
Implicit order of execution can cause problems when
parallelizing build, if there are dependencies between goals
SBT is per default parallel, that's why explicit definition of
task dependencies is needed
It's similar to definition a custom lifecycle in Maven,
which is not easy too
HOW SBT WORKS
PARALLEL EXECUTION
If task A depends on B, and C also depends on B => SBT will
run B first and then A and C in parallel
HOW SBT WORKS
PASSING INFORMATION BETWEEN TASKS
In Maven and ANT it's very hard to pass an information
between tasks
Usually through an intermediate file
In SBT, you can simply return the value from the task and
use it in another dependent task
This makes chaining tasks a lot easier
HOW SBT WORKS
WORKING WITH SCALA
Cross compilation for multiple Scala versions => Scala is
binary compatible only between minor version releases
Not restricted to Scala versions either
scalaVersion := "2.10.1"
crossScalaVersions := Seq("2.8.2", "2.9.2")
libraryDependencies += (scalaBinaryVersion.value match {
case "2.10" => "org.specs2" %% "specs2" % "2.0"
case "2.9.1" => "org.specs2" %% "specs2" % "1.12.4"
})
HOW SBT WORKS
WORKING WITH SCALA, TAKE TWO
Scala compiler generates lots more classes and JVM takes
longer to start-up => interactive environment
Scala compilation is slow (in comparision to Java) =>
incremental compilation
Multi-module builds => parallel execution, child modules
don't need to know about parent module
EXAMPLE OF SIMPLE PROJECT
A COMMON DEVELOPERS USAGE
CORE CONCEPTS
BUILD FILES
build.properties
build.sbt
Blank line is required between settings
project/
build.properties - defines SBT version
plugins.sbt - defines SBT plugins
build.sbt - defines actual build, project settings
sbt.version = 0.12.4
name := "big-project"
version := "1.0"
scalaVersion := "2.10.0"
libraryDependencies += "org.scalatest" %% "scalatest" % "1.9.1" % "
test"
CORE CONCEPTS
SETTINGS
Mechanism to configure a build to to perform th ework we
need to
SBT reads all the settings defined in build at load time and
runs their initializations
name := "big-project"
| | |
key operator intialization
CORE CONCEPTS
SETTINGS, TAKE TWO
Settings are typesafe => every key has only one type and any
value placed into setting must match exact type
Grouping of SettingKey[T]with Initialize[T]
creates Setting[T]
name := "big-project"
| |
SettingKey[String] Initialize[String]
CORE CONCEPTS
SETTINGS, TAKE THREE
Operators used with settings
Types have to match
name := "big-project"
|
assignment
libraryDependencies += "org.scalatest" %% "scalatest" % "1.9.1"
|
append
append multiple values
|
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "1.9.1" % "test",
"org.specs2" %% "specs2" % "2.0" % "test"
)
CORE CONCEPTS
SETTINGS, TAKE FOUR
Initializations are a Scala expressions that can produce value
of desired type
Intializations may use other settings via setting.value
method.
version := "1.0"
libraryDependencies += ("org.scalatest" %% "scalatest" % version.value)
| |
SetingKey[ModuleID] Initialization[ModuleId]
 /
Setting[ModuleID]
CORE CONCEPTS
DEFINING DEPENDENCIES
Definition of exact version
Cross-compiled dependency
groupId % artifactId % version % scope
groupId %% artifactId % version % scope
|
Use appropriate scala version from project
CORE CONCEPTS
CIRCULAR REFERENCES
Because SBT can use values of one setting to instatiate
another, it's possible to create circular references
Build will fail to load when circular references are
detected.
CORE CONCEPTS
CUSTOM TASKS AND SETTINGS
For version 0.12.4 have to be defined in Scala file not sbt
one
From 0.13.0 they can be defined in sbt too
val gitHeadCommitSHA = taskKey[String]("Determines the current git
commit SHA")
|
setting/task definition
gitHeadComitSHA := Process("git rev-parse HEAD").lines.head
| |
setting/task key block of code returning value
Definitions are compiled first and can reference another
definitions
Settings are executed after definitions, hence can refence
any definition
Tasks are executed every time the value is requested
CORE CONCEPTS
CUSTOM TASKS AND SETTINGS
For version 0.12.4 have to be defined in Scala file not sbt
one
From 0.13.0 they can be defined in sbt too
val gitHeadCommitSHA = taskKey[String]("Determines the current git
commit SHA")
|
setting/task definition
gitHeadComitSHA := Process("git rev-parse HEAD").lines.head
| |
setting/task key block of code returning value
Definitions are compiled first and can reference another
definitions
Settings are executed after definitions, hence can refence
any definition
Tasks are executed every time the value is requested
MORE TO COVER
1. Scopes
2. Multi-module projects
3. Basic SBT objects in Scala
THANKS FOR YOUR ATTENTION

Más contenido relacionado

La actualidad más candente

Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with GradleRyan Cuprak
 
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...ZeroTurnaround
 
The world of gradle - an introduction for developers
The world of gradle  - an introduction for developersThe world of gradle  - an introduction for developers
The world of gradle - an introduction for developersTricode (part of Dept)
 
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012Rajmahendra Hegde
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingSchalk Cronjé
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingSchalk Cronjé
 
Gradle - Build system evolved
Gradle - Build system evolvedGradle - Build system evolved
Gradle - Build system evolvedBhagwat Kumar
 
Java build tool_comparison
Java build tool_comparisonJava build tool_comparison
Java build tool_comparisonManav Prasad
 
Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeansRyan Cuprak
 
Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with MavenSid Anand
 
Basic Gradle Plugin Writing
Basic Gradle Plugin WritingBasic Gradle Plugin Writing
Basic Gradle Plugin WritingSchalk Cronjé
 
In the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: GradleIn the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: GradleSkills Matter
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingSchalk Cronjé
 
Why jakarta ee matters (ConFoo 2021)
Why jakarta ee matters (ConFoo 2021)Why jakarta ee matters (ConFoo 2021)
Why jakarta ee matters (ConFoo 2021)Ryan Cuprak
 
Introduction to Apache Ant
Introduction to Apache AntIntroduction to Apache Ant
Introduction to Apache AntShih-Hsiang Lin
 
Gradle - time for another build
Gradle - time for another buildGradle - time for another build
Gradle - time for another buildIgor Khotin
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules uploadRyan Cuprak
 
My "Perfect" Toolchain Setup for Grails Projects
My "Perfect" Toolchain Setup for Grails ProjectsMy "Perfect" Toolchain Setup for Grails Projects
My "Perfect" Toolchain Setup for Grails ProjectsGR8Conf
 

La actualidad más candente (20)

Gradle Introduction
Gradle IntroductionGradle Introduction
Gradle Introduction
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
 
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
 
The world of gradle - an introduction for developers
The world of gradle  - an introduction for developersThe world of gradle  - an introduction for developers
The world of gradle - an introduction for developers
 
GradleFX
GradleFXGradleFX
GradleFX
 
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin Writing
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin Writing
 
Gradle - Build system evolved
Gradle - Build system evolvedGradle - Build system evolved
Gradle - Build system evolved
 
Java build tool_comparison
Java build tool_comparisonJava build tool_comparison
Java build tool_comparison
 
Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeans
 
Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with Maven
 
Basic Gradle Plugin Writing
Basic Gradle Plugin WritingBasic Gradle Plugin Writing
Basic Gradle Plugin Writing
 
In the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: GradleIn the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: Gradle
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin Writing
 
Why jakarta ee matters (ConFoo 2021)
Why jakarta ee matters (ConFoo 2021)Why jakarta ee matters (ConFoo 2021)
Why jakarta ee matters (ConFoo 2021)
 
Introduction to Apache Ant
Introduction to Apache AntIntroduction to Apache Ant
Introduction to Apache Ant
 
Gradle - time for another build
Gradle - time for another buildGradle - time for another build
Gradle - time for another build
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules upload
 
My "Perfect" Toolchain Setup for Grails Projects
My "Perfect" Toolchain Setup for Grails ProjectsMy "Perfect" Toolchain Setup for Grails Projects
My "Perfect" Toolchain Setup for Grails Projects
 

Destacado

Sbt tutorial
Sbt tutorialSbt tutorial
Sbt tutorialGary Gai
 
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
 
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
 
Innovating faster with SBT, Continuous Delivery, and LXC
Innovating faster with SBT, Continuous Delivery, and LXCInnovating faster with SBT, Continuous Delivery, and LXC
Innovating faster with SBT, Continuous Delivery, and LXCkscaldef
 
Hadoop Summit 2013 : Continuous Integration on top of hadoop
Hadoop Summit 2013 : Continuous Integration on top of hadoopHadoop Summit 2013 : Continuous Integration on top of hadoop
Hadoop Summit 2013 : Continuous Integration on top of hadoopWisely chen
 
Continuous Integration for Spark Apps by Sean McIntyre
Continuous Integration for Spark Apps by Sean McIntyreContinuous Integration for Spark Apps by Sean McIntyre
Continuous Integration for Spark Apps by Sean McIntyreSpark Summit
 
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
 

Destacado (10)

SBT Made Simple
SBT Made SimpleSBT Made Simple
SBT Made Simple
 
Sbt tutorial
Sbt tutorialSbt tutorial
Sbt tutorial
 
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
 
A day with sbt
A day with sbtA day with sbt
A day with sbt
 
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)
 
Innovating faster with SBT, Continuous Delivery, and LXC
Innovating faster with SBT, Continuous Delivery, and LXCInnovating faster with SBT, Continuous Delivery, and LXC
Innovating faster with SBT, Continuous Delivery, and LXC
 
Hadoop Summit 2013 : Continuous Integration on top of hadoop
Hadoop Summit 2013 : Continuous Integration on top of hadoopHadoop Summit 2013 : Continuous Integration on top of hadoop
Hadoop Summit 2013 : Continuous Integration on top of hadoop
 
Continuous Integration for Spark Apps by Sean McIntyre
Continuous Integration for Spark Apps by Sean McIntyreContinuous Integration for Spark Apps by Sean McIntyre
Continuous Integration for Spark Apps by Sean McIntyre
 
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)
 
Build application using sbt
Build application using sbtBuild application using sbt
Build application using sbt
 

Similar a SBT Crash Course

How to start using Scala
How to start using ScalaHow to start using Scala
How to start using ScalaNgoc Dao
 
Sbt, idea and eclipse
Sbt, idea and eclipseSbt, idea and eclipse
Sbt, idea and eclipseMike Slinn
 
Lessons Learned: Scala and its Ecosystem
Lessons Learned: Scala and its EcosystemLessons Learned: Scala and its Ecosystem
Lessons Learned: Scala and its EcosystemPetr Hošek
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with GradleRyan Cuprak
 
Dependency injection in scala
Dependency injection in scalaDependency injection in scala
Dependency injection in scalaMichal Bigos
 
Jenkins advance topic
Jenkins advance topicJenkins advance topic
Jenkins advance topicKalkey
 
Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Robert Scholte
 
Kubernetes for Java developers
Kubernetes for Java developersKubernetes for Java developers
Kubernetes for Java developersRobert Barr
 
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)Robert Scholte
 
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipelineKubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipelineKubeAcademy
 
Spark Streaming Info
Spark Streaming InfoSpark Streaming Info
Spark Streaming InfoDoug Chang
 
Prudential Insurance Exp
Prudential Insurance ExpPrudential Insurance Exp
Prudential Insurance ExpAnkit Chohan
 
Maven 2 features
Maven 2 featuresMaven 2 features
Maven 2 featuresAngel Ruiz
 
Java 9 and the impact on Maven Projects (JavaOne 2016)
Java 9 and the impact on Maven Projects (JavaOne 2016)Java 9 and the impact on Maven Projects (JavaOne 2016)
Java 9 and the impact on Maven Projects (JavaOne 2016)Robert Scholte
 

Similar a SBT Crash Course (20)

How to start using Scala
How to start using ScalaHow to start using Scala
How to start using Scala
 
Sbt, idea and eclipse
Sbt, idea and eclipseSbt, idea and eclipse
Sbt, idea and eclipse
 
Lessons Learned: Scala and its Ecosystem
Lessons Learned: Scala and its EcosystemLessons Learned: Scala and its Ecosystem
Lessons Learned: Scala and its Ecosystem
 
Sbt
SbtSbt
Sbt
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
 
Dependency injection in scala
Dependency injection in scalaDependency injection in scala
Dependency injection in scala
 
Play framework
Play frameworkPlay framework
Play framework
 
Jenkins advance topic
Jenkins advance topicJenkins advance topic
Jenkins advance topic
 
Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
kishore_Nokia
kishore_Nokiakishore_Nokia
kishore_Nokia
 
Kubernetes for Java developers
Kubernetes for Java developersKubernetes for Java developers
Kubernetes for Java developers
 
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
 
Apache DeltaSpike: The CDI Toolbox
Apache DeltaSpike: The CDI ToolboxApache DeltaSpike: The CDI Toolbox
Apache DeltaSpike: The CDI Toolbox
 
Apache DeltaSpike the CDI toolbox
Apache DeltaSpike the CDI toolboxApache DeltaSpike the CDI toolbox
Apache DeltaSpike the CDI toolbox
 
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipelineKubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
 
Spark Streaming Info
Spark Streaming InfoSpark Streaming Info
Spark Streaming Info
 
Prudential Insurance Exp
Prudential Insurance ExpPrudential Insurance Exp
Prudential Insurance Exp
 
Maven 2 features
Maven 2 featuresMaven 2 features
Maven 2 features
 
Java 9 and the impact on Maven Projects (JavaOne 2016)
Java 9 and the impact on Maven Projects (JavaOne 2016)Java 9 and the impact on Maven Projects (JavaOne 2016)
Java 9 and the impact on Maven Projects (JavaOne 2016)
 

Último

Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 

Último (20)

DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 

SBT Crash Course

  • 1. SBT CRASH COURSEBy /Michal Bigos @teliatko
  • 2. SBT CRASH COURSE 1. Why SBT 2. How SBT works 3. Example of simple project 4. Core concepts
  • 3. WHY SBT GOOD BUILD TOOL CRITERIA Reproducibility - automating build, gives you more time to do real stuff Conventions - using sensible defaults, no need to specify every last option and command Experience - distilation of developer wisdom, e.g. test before publish Portability - good build tool should protect you from differences betweeen systems Ecosystem - allow to extend build easily
  • 4. WHY SBT LITTLE HISTORY: APACHE ANT Former standard build tool for Java projects Pros: 1. Portability - build is defined in XML by chaining tasks 2. Experience - abillity to explicitly define dependencies between tasks Cons: 1. Conventions - no default build lifecycle, each build is piece of art 2. Ecosystem - not easy to extend, task definition distributed as jar
  • 5. WHY SBT LITTLE HISTORY: APACHE MAVEN Currently heavily used in enterprise Java projects Most opinionated build tool Pros: 1. Portability - build is defined in XML so called POM 2. Experience, Conventions - Maven introduces default lifecycle with its phases and tasks. It promotes declarative dependency management. Cons: 1. Ecosystem - not easy to extend. Maven plug-in archtecrure requires plug-in written in Java, then POMs and packaging and availability in repository.
  • 6. WHY SBT LITTLE HISTORY: GOOD PARTS Default project layout (Maven) Default project behavior (Maven) Declarative dependency management (Maven) Portability (Ant, Maven)
  • 7. WHY SBT FEATURES AT GLACE Uses Scala to describe build Can be used for Java and Scala Minimal configuration (inspired by Maven) A number of build-in tasks Declarative dependency management (using Apache Ivy) Portability Reactive development environment Allows use Scala REPL Incremental compilation Automatic re-compilation with different versions of Scala
  • 8. HOW SBT WORKS TASKS Task based, more like ANT, no phases like in Maven If you want to do something you execute a task If you want to ensure that a task runs after another, add an explicit dependency between the tasks Output of a task is value, which can be of any type and past to any another task Multiple tasks can depend upon the output of the same task By default tasks are executed in parallel Using dependency tree sbt can work out what can be run in parallel or in sequence
  • 9. HOW SBT WORKS DEFAULT STRUCTURE AND LAYOUT Inspired by Maven {project root} project/ build.properties plugins.sbt src/ main/ scala/ java/ resources/ test/ scala/ java/ resources/ target/ build.sbt
  • 10. HOW SBT WORKS TASKS 'VS PLUGINS Appear directly in build definition file, shared via VCS Task can be turned into plugin and shared via repository val gitHeadCommitSHA = taskKey[String]("Determines the current git comm it SHA") gitHeadComitSHA := Process("git rev-parse HEAD").lines.head
  • 11. HOW SBT WORKS PHASES 'VS TASK DEPENDENCIES In Maven, the order of execution tasks in phases always leads to confusion Default goals for a phase are executed before explicitly defined and those are executed in implicit order of definition in POM file Implicit order of execution can cause problems when parallelizing build, if there are dependencies between goals SBT is per default parallel, that's why explicit definition of task dependencies is needed It's similar to definition a custom lifecycle in Maven, which is not easy too
  • 12. HOW SBT WORKS PARALLEL EXECUTION If task A depends on B, and C also depends on B => SBT will run B first and then A and C in parallel
  • 13. HOW SBT WORKS PASSING INFORMATION BETWEEN TASKS In Maven and ANT it's very hard to pass an information between tasks Usually through an intermediate file In SBT, you can simply return the value from the task and use it in another dependent task This makes chaining tasks a lot easier
  • 14. HOW SBT WORKS WORKING WITH SCALA Cross compilation for multiple Scala versions => Scala is binary compatible only between minor version releases Not restricted to Scala versions either scalaVersion := "2.10.1" crossScalaVersions := Seq("2.8.2", "2.9.2") libraryDependencies += (scalaBinaryVersion.value match { case "2.10" => "org.specs2" %% "specs2" % "2.0" case "2.9.1" => "org.specs2" %% "specs2" % "1.12.4" })
  • 15. HOW SBT WORKS WORKING WITH SCALA, TAKE TWO Scala compiler generates lots more classes and JVM takes longer to start-up => interactive environment Scala compilation is slow (in comparision to Java) => incremental compilation Multi-module builds => parallel execution, child modules don't need to know about parent module
  • 16. EXAMPLE OF SIMPLE PROJECT A COMMON DEVELOPERS USAGE
  • 17. CORE CONCEPTS BUILD FILES build.properties build.sbt Blank line is required between settings project/ build.properties - defines SBT version plugins.sbt - defines SBT plugins build.sbt - defines actual build, project settings sbt.version = 0.12.4 name := "big-project" version := "1.0" scalaVersion := "2.10.0" libraryDependencies += "org.scalatest" %% "scalatest" % "1.9.1" % " test"
  • 18.
  • 19. CORE CONCEPTS SETTINGS Mechanism to configure a build to to perform th ework we need to SBT reads all the settings defined in build at load time and runs their initializations name := "big-project" | | | key operator intialization
  • 20. CORE CONCEPTS SETTINGS, TAKE TWO Settings are typesafe => every key has only one type and any value placed into setting must match exact type Grouping of SettingKey[T]with Initialize[T] creates Setting[T] name := "big-project" | | SettingKey[String] Initialize[String]
  • 21. CORE CONCEPTS SETTINGS, TAKE THREE Operators used with settings Types have to match name := "big-project" | assignment libraryDependencies += "org.scalatest" %% "scalatest" % "1.9.1" | append append multiple values | libraryDependencies ++= Seq( "org.scalatest" %% "scalatest" % "1.9.1" % "test", "org.specs2" %% "specs2" % "2.0" % "test" )
  • 22. CORE CONCEPTS SETTINGS, TAKE FOUR Initializations are a Scala expressions that can produce value of desired type Intializations may use other settings via setting.value method. version := "1.0" libraryDependencies += ("org.scalatest" %% "scalatest" % version.value) | | SetingKey[ModuleID] Initialization[ModuleId] / Setting[ModuleID]
  • 23. CORE CONCEPTS DEFINING DEPENDENCIES Definition of exact version Cross-compiled dependency groupId % artifactId % version % scope groupId %% artifactId % version % scope | Use appropriate scala version from project
  • 24. CORE CONCEPTS CIRCULAR REFERENCES Because SBT can use values of one setting to instatiate another, it's possible to create circular references Build will fail to load when circular references are detected.
  • 25. CORE CONCEPTS CUSTOM TASKS AND SETTINGS For version 0.12.4 have to be defined in Scala file not sbt one From 0.13.0 they can be defined in sbt too val gitHeadCommitSHA = taskKey[String]("Determines the current git commit SHA") | setting/task definition gitHeadComitSHA := Process("git rev-parse HEAD").lines.head | | setting/task key block of code returning value
  • 26. Definitions are compiled first and can reference another definitions Settings are executed after definitions, hence can refence any definition Tasks are executed every time the value is requested
  • 27. CORE CONCEPTS CUSTOM TASKS AND SETTINGS For version 0.12.4 have to be defined in Scala file not sbt one From 0.13.0 they can be defined in sbt too val gitHeadCommitSHA = taskKey[String]("Determines the current git commit SHA") | setting/task definition gitHeadComitSHA := Process("git rev-parse HEAD").lines.head | | setting/task key block of code returning value
  • 28. Definitions are compiled first and can reference another definitions Settings are executed after definitions, hence can refence any definition Tasks are executed every time the value is requested
  • 29. MORE TO COVER 1. Scopes 2. Multi-module projects 3. Basic SBT objects in Scala
  • 30. THANKS FOR YOUR ATTENTION