SlideShare uma empresa Scribd logo
1 de 14
Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn
Getting Started with SBT
Ikenna Nwaiwu
Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn
What is SBT ?
Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn
Objectives
• Compile and run code with SBT
• Add managed dependencies to your project
• Run tests
• Publish to a binary repository
• Use a plugin
• Assemble an run a project jar
• Open an SBT project in Intellij
• Write and SBT task
Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn
Task 1:Write a HelloWorld file
• Create a HelloWorld programe in file “HelloWorld.scala”
• Compile it with >scalac
• Run it with >scala HelloWorld
Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn
Task 2: Now lets use SBT for building
• Create a file build.sbt
• Add the following to your sbt file
• name := "Helloworld project”
• version := "1.0"
• - Double space between lines
• Now start sbt in the directory and run >compile and >run
• >exit
Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn
Task 2: SBT for building – ignoring the target
directory
• SBT puts in generated classes and files in the target directory
• You can clean this directory : >clean
• If you use version control, you probably don’t want these files versioned.
Ignore them with .gitignore
$>’echo target/ ‘ > .gitignore
$>git init
$>git status
Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn
Task 3: Lets create the project directory
structure
• Move your HelloWorlds.scala file to
the src/main/scala folder
lib/
src/
main/
resources/
scala/
java/
test/
resources/
scala/
java/
Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn
Task 4: Add a project dependency
• Got to http://www.scalatest.org/install and
add the scalatest project dependency.
• Run > reload
• Run > update
• Run > test
Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn
Task 5: Write a test and run it
import org.scalatest.{FunSuite, Matchers}
class HelloWorldTest extends FunSuite with Matchers {
test("Multiplication"){
val result = HelloWorld.multiply(3, 4)
result shouldBe 12
}
}
• Create a file HelloWorldTest in
src/test/scala/HelloWorldTest.scala
• Now run > test
• What do you get ?
• Implement the missing method in
HelloWorld.scala
• Now run tests again
Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn
Task 6: Using the console and help
• The SBT console loads your project and allows
you invoke your methods and functions from
the command line
• >console
• >scala>:quit
• >help
• >help reload
Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn
Task 6: Publishing your project locally
• Publishing a project: uploading a descriptor (Ivy file or Maven POM) and jar , to
a repository so that other projects can specify your project as a dependency.
• Add the following to your build.sbt
organization := ”com.lagosscala"
• >publishLocal
• You can now create another project and include your HelloWorld code as a
dependency with
libraryDependencies += ”com.lagosscala” %% "helloworld-project" % “1.0”
Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn
Task 7: Adding a plugin to your project
• A plugin can be used to add more tasks to your project
• Lets add a plugin that packages our project with all the dependencies required for
executing it
• sbt assembly - https://github.com/sbt/sbt-assembly
• Create file project/assembly.sbt and add the following addSbtPlugin("com.eed3si9n"
% "sbt-assembly" % "0.14.3”)
• Now reload, update, and run >assembly
• Note the path of the created assembly jar. Can you run it with
java –jar /path/to/project-assembly.jar ?
Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn
Task 8: Open the project in Intellij
• File > Open > Project
• Use the ‘rebuild’ in the sbt pane to reload the project when you need to.
‘Auto import’ detects file changes and does this automatically as well.
Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn
Sbt Concepts: Settings
• An SBT project consists of an immutable map of key- value pairs
• An sbt build definition file, lists Settings (objects of Setting[T]).These are a list of transformations that can be
applied to the sbt project map. For example, they can add an entry to a map or transform an existing entry.
• The sbt build definition is a list of ‘Setting’s.
• A Setting is created by calling methods :=, +=, or ++= on a SettingKey and assigning a value.
• There are 3 kinds of Keys = SettingKey[T], InputKey[T] andTaskKey[T].
• SettingKeys – key for values computed once
• TaskKey – key for value recomputed each time
• InputKey – key for task that takes command line arguments as input
• There are built in keys that come with sbt and these are defined in sbt.Keys._
• You can create a custom key and use that for custom Settings e.g:
• lazy val helloWorld = taskKey[Unit](“My Hello World set task“)
• hello := { println("Hello World!”) }

Mais conteúdo relacionado

Mais procurados

Building Grails Plugins - Tips And Tricks
Building Grails Plugins - Tips And TricksBuilding Grails Plugins - Tips And Tricks
Building Grails Plugins - Tips And Tricks
Mike Hugo
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO Devs
WO Community
 

Mais procurados (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
 
Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with Maven
 
Gradle - Build system evolved
Gradle - Build system evolvedGradle - Build system evolved
Gradle - Build system evolved
 
Basic Gradle Plugin Writing
Basic Gradle Plugin WritingBasic Gradle Plugin Writing
Basic Gradle Plugin Writing
 
Gradle - Build System
Gradle - Build SystemGradle - Build System
Gradle - Build System
 
Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeans
 
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
 
Building Grails Plugins - Tips And Tricks
Building Grails Plugins - Tips And TricksBuilding Grails Plugins - Tips And Tricks
Building Grails Plugins - Tips And Tricks
 
Gradle For Beginners (Serbian Developer Conference 2013 english)
Gradle For Beginners (Serbian Developer Conference 2013 english)Gradle For Beginners (Serbian Developer Conference 2013 english)
Gradle For Beginners (Serbian Developer Conference 2013 english)
 
GradleFX
GradleFXGradleFX
GradleFX
 
Java build tool_comparison
Java build tool_comparisonJava build tool_comparison
Java build tool_comparison
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO Devs
 
Introduction to Apache Ant
Introduction to Apache AntIntroduction to Apache Ant
Introduction to Apache Ant
 
COScheduler
COSchedulerCOScheduler
COScheduler
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules upload
 
Play framework
Play frameworkPlay framework
Play framework
 
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
 
Apache Lucene for Java EE Developers
Apache Lucene for Java EE DevelopersApache Lucene for Java EE Developers
Apache Lucene for Java EE Developers
 
Grails Plugin Best Practices
Grails Plugin Best PracticesGrails Plugin Best Practices
Grails Plugin Best Practices
 

Destaque

MY SIX MONTHS I T REPORT
MY SIX MONTHS I T REPORTMY SIX MONTHS I T REPORT
MY SIX MONTHS I T REPORT
Ikenna Onyeama
 

Destaque (9)

SBT Made Simple
SBT Made SimpleSBT Made Simple
SBT Made Simple
 
Sbt tutorial
Sbt tutorialSbt tutorial
Sbt tutorial
 
A day with sbt
A day with sbtA day with sbt
A day with sbt
 
SIWES Presentation
SIWES PresentationSIWES Presentation
SIWES Presentation
 
my It report
 my It report my It report
my It report
 
MY SIX MONTHS I T REPORT
MY SIX MONTHS I T REPORTMY SIX MONTHS I T REPORT
MY SIX MONTHS I T REPORT
 
I.T. Report
I.T. ReportI.T. Report
I.T. Report
 
Logbook For Industrial Supervision and Training- A Look at Paper and Digital ...
Logbook For Industrial Supervision and Training- A Look at Paper and Digital ...Logbook For Industrial Supervision and Training- A Look at Paper and Digital ...
Logbook For Industrial Supervision and Training- A Look at Paper and Digital ...
 
Indusrial trainning Report presentation
Indusrial trainning Report presentationIndusrial trainning Report presentation
Indusrial trainning Report presentation
 

Semelhante a Getting started with sbt

In this project, you will learn to use some of the team” features o.docx
In this project, you will learn to use some of the team” features o.docxIn this project, you will learn to use some of the team” features o.docx
In this project, you will learn to use some of the team” features o.docx
breaksdayle
 

Semelhante a Getting started with sbt (20)

Jenkins CI
Jenkins CIJenkins CI
Jenkins CI
 
Simple build tool
Simple build toolSimple build tool
Simple build tool
 
Web works hol
Web works holWeb works hol
Web works hol
 
"Project Tye to Tie .NET Microservices", Oleg Karasik
"Project Tye to Tie .NET Microservices", Oleg Karasik"Project Tye to Tie .NET Microservices", Oleg Karasik
"Project Tye to Tie .NET Microservices", Oleg Karasik
 
4.Building a Data Product using apache Zeppelin - Apache Kylin Meetup @Shanghai
4.Building a Data Product using apache Zeppelin - Apache Kylin Meetup @Shanghai4.Building a Data Product using apache Zeppelin - Apache Kylin Meetup @Shanghai
4.Building a Data Product using apache Zeppelin - Apache Kylin Meetup @Shanghai
 
In this project, you will learn to use some of the team” features o.docx
In this project, you will learn to use some of the team” features o.docxIn this project, you will learn to use some of the team” features o.docx
In this project, you will learn to use some of the team” features o.docx
 
Untangling - fall2017 - week 9
Untangling - fall2017 - week 9Untangling - fall2017 - week 9
Untangling - fall2017 - week 9
 
Version control git day01
Version control   git day01Version control   git day01
Version control git day01
 
Version control git day01
Version control   git day01Version control   git day01
Version control git day01
 
Reproducible research: practice
Reproducible research: practiceReproducible research: practice
Reproducible research: practice
 
Eclipse IDE, 2019.09, Java Development
Eclipse IDE, 2019.09, Java Development Eclipse IDE, 2019.09, Java Development
Eclipse IDE, 2019.09, Java Development
 
Make an Instant Website with Webhooks
Make an Instant Website with WebhooksMake an Instant Website with Webhooks
Make an Instant Website with Webhooks
 
SharePoint for Project Management (2016)
SharePoint for Project Management (2016)SharePoint for Project Management (2016)
SharePoint for Project Management (2016)
 
[2015/2016] Collaborative software development with Git
[2015/2016] Collaborative software development with Git[2015/2016] Collaborative software development with Git
[2015/2016] Collaborative software development with Git
 
Makefile+VersionControl
Makefile+VersionControlMakefile+VersionControl
Makefile+VersionControl
 
Developer@sky
Developer@skyDeveloper@sky
Developer@sky
 
Apache Spark™ + IBM Watson + Twitter DataPalooza SF 2015
Apache Spark™ + IBM Watson + Twitter DataPalooza SF 2015Apache Spark™ + IBM Watson + Twitter DataPalooza SF 2015
Apache Spark™ + IBM Watson + Twitter DataPalooza SF 2015
 
Introducing to git
Introducing to gitIntroducing to git
Introducing to git
 
Assignment 2
Assignment 2Assignment 2
Assignment 2
 
R meetup 20161011v2
R meetup 20161011v2R meetup 20161011v2
R meetup 20161011v2
 

Último

Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Último (20)

OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 

Getting started with sbt

  • 1. Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn Getting Started with SBT Ikenna Nwaiwu
  • 2. Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn What is SBT ?
  • 3. Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn Objectives • Compile and run code with SBT • Add managed dependencies to your project • Run tests • Publish to a binary repository • Use a plugin • Assemble an run a project jar • Open an SBT project in Intellij • Write and SBT task
  • 4. Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn Task 1:Write a HelloWorld file • Create a HelloWorld programe in file “HelloWorld.scala” • Compile it with >scalac • Run it with >scala HelloWorld
  • 5. Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn Task 2: Now lets use SBT for building • Create a file build.sbt • Add the following to your sbt file • name := "Helloworld project” • version := "1.0" • - Double space between lines • Now start sbt in the directory and run >compile and >run • >exit
  • 6. Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn Task 2: SBT for building – ignoring the target directory • SBT puts in generated classes and files in the target directory • You can clean this directory : >clean • If you use version control, you probably don’t want these files versioned. Ignore them with .gitignore $>’echo target/ ‘ > .gitignore $>git init $>git status
  • 7. Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn Task 3: Lets create the project directory structure • Move your HelloWorlds.scala file to the src/main/scala folder lib/ src/ main/ resources/ scala/ java/ test/ resources/ scala/ java/
  • 8. Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn Task 4: Add a project dependency • Got to http://www.scalatest.org/install and add the scalatest project dependency. • Run > reload • Run > update • Run > test
  • 9. Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn Task 5: Write a test and run it import org.scalatest.{FunSuite, Matchers} class HelloWorldTest extends FunSuite with Matchers { test("Multiplication"){ val result = HelloWorld.multiply(3, 4) result shouldBe 12 } } • Create a file HelloWorldTest in src/test/scala/HelloWorldTest.scala • Now run > test • What do you get ? • Implement the missing method in HelloWorld.scala • Now run tests again
  • 10. Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn Task 6: Using the console and help • The SBT console loads your project and allows you invoke your methods and functions from the command line • >console • >scala>:quit • >help • >help reload
  • 11. Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn Task 6: Publishing your project locally • Publishing a project: uploading a descriptor (Ivy file or Maven POM) and jar , to a repository so that other projects can specify your project as a dependency. • Add the following to your build.sbt organization := ”com.lagosscala" • >publishLocal • You can now create another project and include your HelloWorld code as a dependency with libraryDependencies += ”com.lagosscala” %% "helloworld-project" % “1.0”
  • 12. Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn Task 7: Adding a plugin to your project • A plugin can be used to add more tasks to your project • Lets add a plugin that packages our project with all the dependencies required for executing it • sbt assembly - https://github.com/sbt/sbt-assembly • Create file project/assembly.sbt and add the following addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.3”) • Now reload, update, and run >assembly • Note the path of the created assembly jar. Can you run it with java –jar /path/to/project-assembly.jar ?
  • 13. Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn Task 8: Open the project in Intellij • File > Open > Project • Use the ‘rebuild’ in the sbt pane to reload the project when you need to. ‘Auto import’ detects file changes and does this automatically as well.
  • 14. Ikenna Consulting ikenna@ikenna.net Twitter: @ikennacn Sbt Concepts: Settings • An SBT project consists of an immutable map of key- value pairs • An sbt build definition file, lists Settings (objects of Setting[T]).These are a list of transformations that can be applied to the sbt project map. For example, they can add an entry to a map or transform an existing entry. • The sbt build definition is a list of ‘Setting’s. • A Setting is created by calling methods :=, +=, or ++= on a SettingKey and assigning a value. • There are 3 kinds of Keys = SettingKey[T], InputKey[T] andTaskKey[T]. • SettingKeys – key for values computed once • TaskKey – key for value recomputed each time • InputKey – key for task that takes command line arguments as input • There are built in keys that come with sbt and these are defined in sbt.Keys._ • You can create a custom key and use that for custom Settings e.g: • lazy val helloWorld = taskKey[Unit](“My Hello World set task“) • hello := { println("Hello World!”) }

Notas do Editor

  1. Note that SBT can run interactively or in batch mode >sbt compile run Note we are using ‘bare build definitions’ (pre 0.13.7) 1. Multi-project .sbt build definition 2. Bare .sbt build definition 3. .scala build definition
  2. Note that SBT can run interactively or in batch mode >sbt compile run
  3. Note that SBT can run interactively or in batch mode Also note target and project are top level directories
  4. libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % "test"
  5. Just tests first
  6. >console You can run scala code on the console >scala> HelloWorld.multiply(4, 6)