Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
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

Recommended for you

Gradle - Build system evolved
Gradle - Build system evolvedGradle - Build system evolved
Gradle - Build system evolved

Gradle is a general-purpose build automation tool. It combines the power and flexibility of Ant with the dependency management and conventions of Maven into a more effective way to build. Its powered by Groovy DSL. Presentation discusses what and why Gradle with demo for java, groovy, web, multi-project and grails projects.

javagradlegrails
Basic Gradle Plugin Writing
Basic Gradle Plugin WritingBasic Gradle Plugin Writing
Basic Gradle Plugin Writing

This document provides a 3 sentence summary of the presentation "Idiomatic Gradle Plugin Writing" by Schalk W. Cronjé: The presentation discusses best practices for writing Gradle plugins, including using consistent and readable extensions to the Gradle DSL, supporting offline mode, testing plugins against multiple Gradle versions, and extending existing task types when needed rather than forcing users to use standard configurations. It provides examples of idiomatic ways to handle collections, maps, dependencies, and project extensions within Gradle plugins. The presentation aims to promote quality attributes like readability, consistency, flexibility and expressiveness in plugin authoring.

gradle
Gradle - Build System
Gradle - Build SystemGradle - Build System
Gradle - Build System

A general- ‐purpose build automation tool. It can automate building, testing, deployment, publishing, generate documentation etc. Designed to take advantage of convention over configuration. Combines the power and flexibility of Ant with the dependency management and conventions of Maven into a more effective way to build.

build toolgradlegroovy
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

Recommended for you

Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeans

This session covers the basics of developing Node.js applications with NetBeans. NetBeans includes fully integrated support for both JavaScript and Node.js. You’ll get a tour of the features and learn how NetBeans can accelerate your projects. The presentation looks at basic code editing capabilities provided by the IDE, tool integration (npm/Grunt/Bower/Webpack), frameworks such as Express, and debugging capabilities. You’ll see why NetBeans is the best free JavaScript/Node.js IDE.

nodejsnetbeansaws lambda
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

Presentationslides from the GR8Conf presentation. Find the abstract here: http://gr8conf.eu/Presentations/my-perfect-grails-toolchain

grailsgr8confsetup
Building Grails Plugins - Tips And Tricks
Building Grails Plugins - Tips And TricksBuilding Grails Plugins - Tips And Tricks
Building Grails Plugins - Tips And Tricks

This document provides an overview of building Grails plugins, including tips and tricks. It discusses creating a plugin project structure, testing plugins, adding configuration, events, and internationalization. It also covers integrating plugins into applications, reloading changes during development, and publishing plugins for others to use.

plugingrailsgroovy
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 ?

Recommended for you

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)

The document provides an overview of Gradle for beginners. It discusses Gradle basics like build scripts, conventions over configuration, and the configuration and execution phases. It also covers tasks, plugins, dependencies, repositories, testing, quality assurance, and publishing artifacts. An example project is presented that shows how to build an application with Gradle, including tests, dependencies, plugins, and publishing the build artifacts.

gradlegroovyprogramming
GradleFX
GradleFXGradleFX
GradleFX

This document introduces GradleFx, a Flex build tool that uses Gradle. It discusses key features of GradleFx such as supporting SWC, SWF, and AIR compilation; tasks for cleaning, compiling, packaging, and testing; and conventions for project structure and dependencies. Advanced topics covered include compiler options, JVM arguments, dependency configurations, and additional steps for AIR projects and FlexUnit testing. An example Gradle build script is provided.

Java build tool_comparison
Java build tool_comparisonJava build tool_comparison
Java build tool_comparison

The document compares several Java build tools: Ant + Ivy, Maven, Gradle, and Buildr. It describes their key features such as dependency management, build lifecycles, and conventions. A results matrix shows how well each tool supports desired build features such as compiling Java code, running tests, and property expansion. The evaluation notes that Ant, Ivy and Maven have been around longest but Gradle is promising. Buildr is considered very flexible but has potential platform issues being built on Ruby.

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!”) }

More Related Content

What's hot

Gradle Introduction
Gradle IntroductionGradle Introduction
Gradle Introduction
Dmitry Buzdin
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
Ryan Cuprak
 
Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with Maven
Sid Anand
 
Gradle - Build system evolved
Gradle - Build system evolvedGradle - Build system evolved
Gradle - Build system evolved
Bhagwat Kumar
 
Basic Gradle Plugin Writing
Basic Gradle Plugin WritingBasic Gradle Plugin Writing
Basic Gradle Plugin Writing
Schalk Cronjé
 
Gradle - Build System
Gradle - Build SystemGradle - Build System
Gradle - Build System
Jeevesh Pandey
 
Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeans
Ryan 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 Projects
GR8Conf
 
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
 
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)
Joachim Baumann
 
GradleFX
GradleFXGradleFX
Java build tool_comparison
Java build tool_comparisonJava build tool_comparison
Java build tool_comparison
Manav Prasad
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO Devs
WO Community
 
Introduction to Apache Ant
Introduction to Apache AntIntroduction to Apache Ant
Introduction to Apache Ant
Shih-Hsiang Lin
 
COScheduler
COSchedulerCOScheduler
COScheduler
WO Community
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules upload
Ryan Cuprak
 
Play framework
Play frameworkPlay framework
Play framework
Andrew Skiba
 
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
Rajmahendra Hegde
 
Apache Lucene for Java EE Developers
Apache Lucene for Java EE DevelopersApache Lucene for Java EE Developers
Apache Lucene for Java EE Developers
Virtual JBoss User Group
 
Grails Plugin Best Practices
Grails Plugin Best PracticesGrails Plugin Best Practices
Grails Plugin Best Practices
Burt Beckwith
 

What's hot (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
 

Viewers also liked

SBT Made Simple
SBT Made SimpleSBT Made Simple
SBT Made Simple
Fuqiang Wang
 
Sbt tutorial
Sbt tutorialSbt tutorial
Sbt tutorial
Gary Gai
 
A day with sbt
A day with sbtA day with sbt
A day with sbt
Marcus Lönnberg
 
SIWES Presentation
SIWES PresentationSIWES Presentation
SIWES Presentation
Adams T. Davids
 
my It report
 my It report my It report
my It report
stevotexas
 
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
 
I.T. Report
I.T. ReportI.T. Report
I.T. Report
Olusegun Falaye
 
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 ...
Olufemi Jeremiah Olubodun
 
Indusrial trainning Report presentation
Indusrial trainning Report presentationIndusrial trainning Report presentation
Indusrial trainning Report presentation
Abdulafeez Fasasi
 

Viewers also liked (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
 

Similar to Getting started with sbt

Jenkins CI
Jenkins CIJenkins CI
Jenkins CI
Viyaan Jhiingade
 
Simple build tool
Simple build toolSimple build tool
Simple build tool
Knoldus Inc.
 
Web works hol
Web works holWeb works hol
Web works hol
momoahmedabad
 
"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
Fwdays
 
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
Luke Han
 
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
 
Untangling - fall2017 - week 9
Untangling - fall2017 - week 9Untangling - fall2017 - week 9
Untangling - fall2017 - week 9
Derek Jacoby
 
Version control git day01
Version control   git day01Version control   git day01
Version control git day01
Gourav Varma
 
Version control git day01
Version control   git day01Version control   git day01
Version control git day01
Gourav Varma
 
Reproducible research: practice
Reproducible research: practiceReproducible research: practice
Reproducible research: practice
C. Tobin Magle
 
Eclipse IDE, 2019.09, Java Development
Eclipse IDE, 2019.09, Java Development Eclipse IDE, 2019.09, Java Development
Eclipse IDE, 2019.09, Java Development
Pei-Hsuan Hsieh
 
Make an Instant Website with Webhooks
Make an Instant Website with WebhooksMake an Instant Website with Webhooks
Make an Instant Website with Webhooks
Anne Gentle
 
SharePoint for Project Management (2016)
SharePoint for Project Management (2016)SharePoint for Project Management (2016)
SharePoint for Project Management (2016)
wandersick
 
[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
Ivano Malavolta
 
Makefile+VersionControl
Makefile+VersionControlMakefile+VersionControl
Makefile+VersionControl
Aashish Sawhney
 
Developer@sky
Developer@skyDeveloper@sky
Developer@sky
Claudia Danciu
 
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
Mike Broberg
 
Introducing to git
Introducing to gitIntroducing to git
Introducing to git
Sajjad Rad
 
Assignment 2
Assignment 2Assignment 2
Assignment 2
Conor Dorrian
 
R meetup 20161011v2
R meetup 20161011v2R meetup 20161011v2
R meetup 20161011v2
Niels Ole Dam
 

Similar to 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
 

Recently uploaded

mobile-app-development-company-in-noida.pdf
mobile-app-development-company-in-noida.pdfmobile-app-development-company-in-noida.pdf
mobile-app-development-company-in-noida.pdf
Mobile App Development Company in Noida - Drona Infotech
 
Java SE 17 Study Guide for Certification - Chapter 01
Java SE 17 Study Guide for Certification - Chapter 01Java SE 17 Study Guide for Certification - Chapter 01
Java SE 17 Study Guide for Certification - Chapter 01
williamrobertherman
 
ANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdfANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdf
sachin chaurasia
 
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple StepsSeamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Estuary Flow
 
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
avufu
 
Break data silos with real-time connectivity using Confluent Cloud Connectors
Break data silos with real-time connectivity using Confluent Cloud ConnectorsBreak data silos with real-time connectivity using Confluent Cloud Connectors
Break data silos with real-time connectivity using Confluent Cloud Connectors
confluent
 
How we built TryBoxLang in under 48 hours
How we built TryBoxLang in under 48 hoursHow we built TryBoxLang in under 48 hours
How we built TryBoxLang in under 48 hours
Ortus Solutions, Corp
 
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Asher Sterkin
 
₹Call ₹Girls Andheri West 09967584737 Deshi Chori Near You
₹Call ₹Girls Andheri West 09967584737 Deshi Chori Near You₹Call ₹Girls Andheri West 09967584737 Deshi Chori Near You
₹Call ₹Girls Andheri West 09967584737 Deshi Chori Near You
shristi verma
 
Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024
Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024
Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024
ThousandEyes
 
Kolkata @ℂall @Girls ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
Kolkata @ℂall @Girls ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model SafeKolkata @ℂall @Girls ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
Kolkata @ℂall @Girls ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
Misti Soneji
 
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
dachnug51 - HCLs evolution of the employee experience platform.pdf
dachnug51 - HCLs evolution of the employee experience platform.pdfdachnug51 - HCLs evolution of the employee experience platform.pdf
dachnug51 - HCLs evolution of the employee experience platform.pdf
DNUG e.V.
 
Chennai @Call @Girls 🐱‍🐉 XXXXXXXXXX 🐱‍🐉 Genuine WhatsApp Number for Real Meet
Chennai @Call @Girls 🐱‍🐉  XXXXXXXXXX 🐱‍🐉 Genuine WhatsApp Number for Real MeetChennai @Call @Girls 🐱‍🐉  XXXXXXXXXX 🐱‍🐉 Genuine WhatsApp Number for Real Meet
Chennai @Call @Girls 🐱‍🐉 XXXXXXXXXX 🐱‍🐉 Genuine WhatsApp Number for Real Meet
lovelykumarilk789
 
Bhiwandi @Call @Girls Whatsapp 000000000 With Best And No 1
Bhiwandi @Call @Girls Whatsapp 000000000 With Best And No 1Bhiwandi @Call @Girls Whatsapp 000000000 With Best And No 1
Bhiwandi @Call @Girls Whatsapp 000000000 With Best And No 1
arvindkumarji156
 
@Call @Girls in Ahmedabad 🐱‍🐉 XXXXXXXXXX 🐱‍🐉 Best High Class Ahmedabad Ava...
 @Call @Girls in Ahmedabad 🐱‍🐉  XXXXXXXXXX 🐱‍🐉  Best High Class Ahmedabad Ava... @Call @Girls in Ahmedabad 🐱‍🐉  XXXXXXXXXX 🐱‍🐉  Best High Class Ahmedabad Ava...
@Call @Girls in Ahmedabad 🐱‍🐉 XXXXXXXXXX 🐱‍🐉 Best High Class Ahmedabad Ava...
DiyaSharma6551
 
What is OCR Technology and How to Extract Text from Any Image for Free
What is OCR Technology and How to Extract Text from Any Image for FreeWhat is OCR Technology and How to Extract Text from Any Image for Free
What is OCR Technology and How to Extract Text from Any Image for Free
TwisterTools
 
Splunk_Remote_Work_Insights_Overview.pptx
Splunk_Remote_Work_Insights_Overview.pptxSplunk_Remote_Work_Insights_Overview.pptx
Splunk_Remote_Work_Insights_Overview.pptx
sudsdeep
 
Dombivli @Call @Girls 🛴 9930687706 🛴 Aaradhaya Best High Class Mumbai Available
Dombivli @Call @Girls 🛴 9930687706 🛴 Aaradhaya Best High Class Mumbai AvailableDombivli @Call @Girls 🛴 9930687706 🛴 Aaradhaya Best High Class Mumbai Available
Dombivli @Call @Girls 🛴 9930687706 🛴 Aaradhaya Best High Class Mumbai Available
cristine510
 
Addressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptxAddressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptx
Sparity1
 

Recently uploaded (20)

mobile-app-development-company-in-noida.pdf
mobile-app-development-company-in-noida.pdfmobile-app-development-company-in-noida.pdf
mobile-app-development-company-in-noida.pdf
 
Java SE 17 Study Guide for Certification - Chapter 01
Java SE 17 Study Guide for Certification - Chapter 01Java SE 17 Study Guide for Certification - Chapter 01
Java SE 17 Study Guide for Certification - Chapter 01
 
ANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdfANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdf
 
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple StepsSeamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
 
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
 
Break data silos with real-time connectivity using Confluent Cloud Connectors
Break data silos with real-time connectivity using Confluent Cloud ConnectorsBreak data silos with real-time connectivity using Confluent Cloud Connectors
Break data silos with real-time connectivity using Confluent Cloud Connectors
 
How we built TryBoxLang in under 48 hours
How we built TryBoxLang in under 48 hoursHow we built TryBoxLang in under 48 hours
How we built TryBoxLang in under 48 hours
 
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
 
₹Call ₹Girls Andheri West 09967584737 Deshi Chori Near You
₹Call ₹Girls Andheri West 09967584737 Deshi Chori Near You₹Call ₹Girls Andheri West 09967584737 Deshi Chori Near You
₹Call ₹Girls Andheri West 09967584737 Deshi Chori Near You
 
Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024
Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024
Cisco Live Announcements: New ThousandEyes Release Highlights - July 2024
 
Kolkata @ℂall @Girls ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
Kolkata @ℂall @Girls ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model SafeKolkata @ℂall @Girls ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
Kolkata @ℂall @Girls ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
 
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
 
dachnug51 - HCLs evolution of the employee experience platform.pdf
dachnug51 - HCLs evolution of the employee experience platform.pdfdachnug51 - HCLs evolution of the employee experience platform.pdf
dachnug51 - HCLs evolution of the employee experience platform.pdf
 
Chennai @Call @Girls 🐱‍🐉 XXXXXXXXXX 🐱‍🐉 Genuine WhatsApp Number for Real Meet
Chennai @Call @Girls 🐱‍🐉  XXXXXXXXXX 🐱‍🐉 Genuine WhatsApp Number for Real MeetChennai @Call @Girls 🐱‍🐉  XXXXXXXXXX 🐱‍🐉 Genuine WhatsApp Number for Real Meet
Chennai @Call @Girls 🐱‍🐉 XXXXXXXXXX 🐱‍🐉 Genuine WhatsApp Number for Real Meet
 
Bhiwandi @Call @Girls Whatsapp 000000000 With Best And No 1
Bhiwandi @Call @Girls Whatsapp 000000000 With Best And No 1Bhiwandi @Call @Girls Whatsapp 000000000 With Best And No 1
Bhiwandi @Call @Girls Whatsapp 000000000 With Best And No 1
 
@Call @Girls in Ahmedabad 🐱‍🐉 XXXXXXXXXX 🐱‍🐉 Best High Class Ahmedabad Ava...
 @Call @Girls in Ahmedabad 🐱‍🐉  XXXXXXXXXX 🐱‍🐉  Best High Class Ahmedabad Ava... @Call @Girls in Ahmedabad 🐱‍🐉  XXXXXXXXXX 🐱‍🐉  Best High Class Ahmedabad Ava...
@Call @Girls in Ahmedabad 🐱‍🐉 XXXXXXXXXX 🐱‍🐉 Best High Class Ahmedabad Ava...
 
What is OCR Technology and How to Extract Text from Any Image for Free
What is OCR Technology and How to Extract Text from Any Image for FreeWhat is OCR Technology and How to Extract Text from Any Image for Free
What is OCR Technology and How to Extract Text from Any Image for Free
 
Splunk_Remote_Work_Insights_Overview.pptx
Splunk_Remote_Work_Insights_Overview.pptxSplunk_Remote_Work_Insights_Overview.pptx
Splunk_Remote_Work_Insights_Overview.pptx
 
Dombivli @Call @Girls 🛴 9930687706 🛴 Aaradhaya Best High Class Mumbai Available
Dombivli @Call @Girls 🛴 9930687706 🛴 Aaradhaya Best High Class Mumbai AvailableDombivli @Call @Girls 🛴 9930687706 🛴 Aaradhaya Best High Class Mumbai Available
Dombivli @Call @Girls 🛴 9930687706 🛴 Aaradhaya Best High Class Mumbai Available
 
Addressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptxAddressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptx
 

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!”) }

Editor's Notes

  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)