SlideShare a Scribd company logo
SBT
Tomer Ben David
Contents
Brief overview of SBT
SBT maven plugin for integration with MAVEN!
So we can reuse Maven Infrastructure
SBT - scala build tool
More teams are joining scala coding
Spark development is mostly done in scala
SBT got much inspired by maven
Modelling is good in maven, behaviour is somewhat harder (xml)
SBT can join forces with maven model in maven behaviour in scala
With richness comes complexity
You can run SBT with no code
Main object
run sbt run
it compile and runs
expected maven style directory structure
src/main/scala or java
define a project
build.sbt in root folder
lazy val root = (project in file(“.”)).
settings(
name := “hello”,
version := “1.0
project dir
can contain scala files
ie
Build.scala
Interactive mode
sbt console
Continuous build
~ compile
will compile upon changes
History commands
!
!!
Build definition
each project associated with immutable map key value pairs
keys have a method named :=
This method returns back Settings
build does not change map
it create settings which is a set of transformations on key value pairs
Three flavour of keys
SettingKey
TaskKey - computed each time potentially with side effects
compile, package they can have return value or no return value
InputKey
Built in keys
sbt.Keys._
Create example taskKey
lazy val hello = taskKey[Unit](“An example key”)
Assign value - operation to a task
task key
lazy val hello = taskKey[Unit](“an example task key”)
task value (operation)
lazy val root = (project in file(“.”)).
settings(
hello := { println(“hello”) }
)
“compile” is a task key
dependencies
val derby = “org.apache.derby” % “derby” % “10.4.1.3”
later on: libraryDependencies += derby
+= appends to the keys old value rather than replace
Scopes
in truth a key can have different value in different scopes
a key can have different value for each project
compile key can have different values for source and test source if you want to
compile them differently
packageOptions can have different values when packging class files or source
code
There is a single value for a given scoped key
Setting key in scopes
name in (Compile, packageBin) := “hello”
Set the source directory for compile
sourceDirectory in Compile += new File(“source”)
Refer to key’s value
organization := name.value
name := baseDirectory.value.getName
Examples
name := "99-scala-solutions"
version := "0.1"
description := "99 scala solutions"
startYear := Some(2015)
licenses += "Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-
2.0.html")
Examples
val commonScalacOptions = Seq(
"-encoding", "UTF-8" // Specify character encoding used by source files
, "-target:jvm-1.8" // Target platform for object files
, "-Xexperimental" // Enable experimental extensions
, "-Xfuture" // Turn on future language features
, "-Ybackend:GenBCode" // Choice of bytecode emitter
)
scalacOptions ++= commonScalacOptions ++ Seq(
"-deprecation" // Emit warning and location for usages of deprecated APIs
, "-feature" // Emit warning and location for usages of features that should be imported explicitly
, "-g:vars"
Examples
Examples
settings(
startServer := {
println(“starting”)
Thread.sleep(500)
then from sbt commandline
sbt> startServer
SBT Maven Plugin

More Related Content

PDF
Phoenix for Rails Devs
PPTX
Breaking Up With Your Data Center Presentation
PDF
Google App Engine With Java And Groovy
PDF
Cocoapods and Most common used library in Swift
PPTX
Basics of Ansible - Sahil Davawala
PPTX
Deploying your web application with AWS ElasticBeanstalk
PPTX
Chef advance
PDF
Phoenix for Rails Devs
Breaking Up With Your Data Center Presentation
Google App Engine With Java And Groovy
Cocoapods and Most common used library in Swift
Basics of Ansible - Sahil Davawala
Deploying your web application with AWS ElasticBeanstalk
Chef advance

What's hot (19)

PDF
CI/CD with Kubernetes, Helm & Wercker (#madScalability)
PDF
What's New in v2 - AnsibleFest London 2015
PPT
A Brief Introduce to WSGI
PDF
2017 JCP EC: Configuration JSR
PPTX
Openshift Container Platform on Azure
PDF
Continuous Testing with Molecule, Ansible, and GitHub Actions
PDF
Ansible
PDF
Scripting Embulk Plugins
PDF
Ansible 2 and Ansible Galaxy 2
PPTX
Cyansible
KEY
2011/10/08_Playframework_GAE_to_Heroku
PPTX
Drupal 8 + Elasticsearch + Docker
PDF
Ansible - Hands on Training
PDF
Kube-AWS
PDF
PPTX
Sim a Microsoft Utiliza OpenSource em DevOps!
PDF
[OpenInfra Days Korea 2018] Day 2 - E5-1: "Invited Talk: Kubicorn - Building ...
PPTX
Display eea’s semantic content with elasticsearch and node.js applications sh...
PDF
Python WSGI introduction
CI/CD with Kubernetes, Helm & Wercker (#madScalability)
What's New in v2 - AnsibleFest London 2015
A Brief Introduce to WSGI
2017 JCP EC: Configuration JSR
Openshift Container Platform on Azure
Continuous Testing with Molecule, Ansible, and GitHub Actions
Ansible
Scripting Embulk Plugins
Ansible 2 and Ansible Galaxy 2
Cyansible
2011/10/08_Playframework_GAE_to_Heroku
Drupal 8 + Elasticsearch + Docker
Ansible - Hands on Training
Kube-AWS
Sim a Microsoft Utiliza OpenSource em DevOps!
[OpenInfra Days Korea 2018] Day 2 - E5-1: "Invited Talk: Kubicorn - Building ...
Display eea’s semantic content with elasticsearch and node.js applications sh...
Python WSGI introduction
Ad

Similar to Sbt (20)

PDF
SBT Crash Course
PDF
Sbt for mere mortals
PPT
Simple build tool
PPTX
Lessons Learned: Scala and its Ecosystem
PDF
Ejb3 Struts Tutorial En
PDF
Ejb3 Struts Tutorial En
PDF
Briefly: Scala Implicits, Pimp My Library and Java Interop
PDF
Configuration Management in Drupal 8: A preview (DrupalCamp Alpe Adria 2014)
PPTX
SBT Concepts, part 2
PDF
Ruby On Rails
ODP
Refactoring to Scala DSLs and LiftOff 2009 Recap
PDF
jclouds High Level Overview by Adrian Cole
PDF
Binary Packaging for HPC with Spack
PPT
An introduction to maven gradle and sbt
PPT
Sbt, idea and eclipse
ODP
How to start using Scala
PPTX
SBT by Aform Research, Saulius Valatka
KEY
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
PPT
Rails Rookies Bootcamp - Blogger
SBT Crash Course
Sbt for mere mortals
Simple build tool
Lessons Learned: Scala and its Ecosystem
Ejb3 Struts Tutorial En
Ejb3 Struts Tutorial En
Briefly: Scala Implicits, Pimp My Library and Java Interop
Configuration Management in Drupal 8: A preview (DrupalCamp Alpe Adria 2014)
SBT Concepts, part 2
Ruby On Rails
Refactoring to Scala DSLs and LiftOff 2009 Recap
jclouds High Level Overview by Adrian Cole
Binary Packaging for HPC with Spack
An introduction to maven gradle and sbt
Sbt, idea and eclipse
How to start using Scala
SBT by Aform Research, Saulius Valatka
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
Rails Rookies Bootcamp - Blogger
Ad

More from Tomer Ben David (7)

PPTX
Couchbase community vs enterprise
PPTX
Caching concepts part 1
PPTX
Actors, akka, streams
PPTX
Scala 5 Concepts and Pitfals
PPTX
Apache Cassandra Concepts CheatSheet
PPTX
Best DevOps resources
PPTX
Scala diamond
Couchbase community vs enterprise
Caching concepts part 1
Actors, akka, streams
Scala 5 Concepts and Pitfals
Apache Cassandra Concepts CheatSheet
Best DevOps resources
Scala diamond

Recently uploaded (20)

PDF
Paper PDF World Game (s) Great Redesign.pdf
PDF
Decoding a Decade: 10 Years of Applied CTI Discipline
PDF
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
PPTX
Funds Management Learning Material for Beg
PPT
tcp ip networks nd ip layering assotred slides
PDF
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
PPTX
Introduction to Information and Communication Technology
PDF
Tenda Login Guide: Access Your Router in 5 Easy Steps
PDF
Slides PDF The World Game (s) Eco Economic Epochs.pdf
PDF
RPKI Status Update, presented by Makito Lay at IDNOG 10
PPTX
SAP Ariba Sourcing PPT for learning material
PPTX
522797556-Unit-2-Temperature-measurement-1-1.pptx
PPTX
Digital Literacy And Online Safety on internet
PPTX
Job_Card_System_Styled_lorem_ipsum_.pptx
PPTX
Introuction about WHO-FIC in ICD-10.pptx
DOCX
Unit-3 cyber security network security of internet system
PPTX
presentation_pfe-universite-molay-seltan.pptx
PPTX
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
PPTX
PptxGenJS_Demo_Chart_20250317130215833.pptx
PPTX
INTERNET------BASICS-------UPDATED PPT PRESENTATION
Paper PDF World Game (s) Great Redesign.pdf
Decoding a Decade: 10 Years of Applied CTI Discipline
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
Funds Management Learning Material for Beg
tcp ip networks nd ip layering assotred slides
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
Introduction to Information and Communication Technology
Tenda Login Guide: Access Your Router in 5 Easy Steps
Slides PDF The World Game (s) Eco Economic Epochs.pdf
RPKI Status Update, presented by Makito Lay at IDNOG 10
SAP Ariba Sourcing PPT for learning material
522797556-Unit-2-Temperature-measurement-1-1.pptx
Digital Literacy And Online Safety on internet
Job_Card_System_Styled_lorem_ipsum_.pptx
Introuction about WHO-FIC in ICD-10.pptx
Unit-3 cyber security network security of internet system
presentation_pfe-universite-molay-seltan.pptx
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
PptxGenJS_Demo_Chart_20250317130215833.pptx
INTERNET------BASICS-------UPDATED PPT PRESENTATION

Sbt

  • 2. Contents Brief overview of SBT SBT maven plugin for integration with MAVEN! So we can reuse Maven Infrastructure
  • 3. SBT - scala build tool More teams are joining scala coding Spark development is mostly done in scala SBT got much inspired by maven Modelling is good in maven, behaviour is somewhat harder (xml) SBT can join forces with maven model in maven behaviour in scala With richness comes complexity
  • 4. You can run SBT with no code Main object run sbt run it compile and runs expected maven style directory structure src/main/scala or java
  • 5. define a project build.sbt in root folder lazy val root = (project in file(“.”)). settings( name := “hello”, version := “1.0
  • 6. project dir can contain scala files ie Build.scala
  • 8. Continuous build ~ compile will compile upon changes
  • 10. Build definition each project associated with immutable map key value pairs keys have a method named := This method returns back Settings build does not change map it create settings which is a set of transformations on key value pairs
  • 11. Three flavour of keys SettingKey TaskKey - computed each time potentially with side effects compile, package they can have return value or no return value InputKey
  • 13. Create example taskKey lazy val hello = taskKey[Unit](“An example key”)
  • 14. Assign value - operation to a task task key lazy val hello = taskKey[Unit](“an example task key”) task value (operation) lazy val root = (project in file(“.”)). settings( hello := { println(“hello”) } )
  • 15. “compile” is a task key
  • 16. dependencies val derby = “org.apache.derby” % “derby” % “10.4.1.3” later on: libraryDependencies += derby += appends to the keys old value rather than replace
  • 17. Scopes in truth a key can have different value in different scopes a key can have different value for each project compile key can have different values for source and test source if you want to compile them differently packageOptions can have different values when packging class files or source code There is a single value for a given scoped key
  • 18. Setting key in scopes name in (Compile, packageBin) := “hello”
  • 19. Set the source directory for compile sourceDirectory in Compile += new File(“source”)
  • 20. Refer to key’s value organization := name.value name := baseDirectory.value.getName
  • 21. Examples name := "99-scala-solutions" version := "0.1" description := "99 scala solutions" startYear := Some(2015) licenses += "Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE- 2.0.html")
  • 22. Examples val commonScalacOptions = Seq( "-encoding", "UTF-8" // Specify character encoding used by source files , "-target:jvm-1.8" // Target platform for object files , "-Xexperimental" // Enable experimental extensions , "-Xfuture" // Turn on future language features , "-Ybackend:GenBCode" // Choice of bytecode emitter ) scalacOptions ++= commonScalacOptions ++ Seq( "-deprecation" // Emit warning and location for usages of deprecated APIs , "-feature" // Emit warning and location for usages of features that should be imported explicitly , "-g:vars"