O'Reilly logo
live online training icon Live Online training

Setting up Scala projects

Use sbt, Maven, Gradle, or Mill to create projects and import them into your favorite IDE or editor

Daniel Hinojosa

Scala is a dynamic, general-purpose programming language for the Java Virtual Machine (JVM). However, those new to Scala often find it challenging to get started, since Scala is not the primary language on the JVM. At the same time, the explosion of available alternate editors, IDEs, and package installers offers a bewildering array of choices for setting up a basic project. Scala expert Daniel Hinojosa cuts through the complexity, offering a simple, hands-on guide to setting up a Scala project using sbt (the Simple Build Tool)—currently the favored build tool in the Scala ecosystem.

Over three hours, Daniel walks you through creating Scala projects with sbt and bringing those projects into your favorite IDE or editor. You'll also discover how to add and reload dependencies and explore other build common tools like Maven, Gradle, and Mill. You'll leave ready to use sbt to manage your projects.

This class is a great follow-up if you’ve taken Daniel’s Learn the basics of Scala in 3 hours course or if you already understand concepts such as manipulating variables, classes, and functions in Scala.

What you'll learn-and how you can apply it

By the end of this live online course, you’ll understand:

  • How to set up a project in sbt
  • sbt basic commands
  • How to do basic project management in sbt
  • How to set up testing with ScalaTest

And you’ll be able to:

  • Add or update dependencies
  • Bring your project into your favorite editor, such as IntelliJ, IDEA, Eclipse, or VS Code
  • Create a project in other build tools like Maven, Gradle, and Mill

This training course is for you because...

  • You're interested in creating a project in Scala.
  • You have questions regarding setup, the typical toolchain, and the best way to get started with Scala.
  • You want to set up and get started with testing with Scala.

Prerequisites

Materials or downloads needed in advance:

  • A machine with the latest JDK 8 or JDK 9, Scala, the latest IntelliJ or Eclipse with the Scala and Scala-IDE plug-ins, and sbt installed and set up

Recommended preparation:

Recommended follow-up:

About your instructor

  • Daniel Hinojosa is an instructor, speaker, author, programmer, and consultant with over 20 years of experience working with private, educational, and government institutions. He is also currently a speaker on the No Fluff Just Stuff tour. Daniel loves JVM languages like Java, Groovy, and Scala, but he also dabbles with non-JVM languages like Haskell, Ruby, Python, Lisp, C, and C++. He is an avid Pomodoro Technique practitioner and attempts to learn a new programming language every year. Daniel is the author of Testing in Scala and the video Beginning Scala Programming as well as the teacher of a line of training courses, all for O’Reilly. In his downtime, he enjoys reading, swimming, playing with Legos, and cooking.

Schedule

The timeframes are only estimates and may vary according to how the class is progressing

sbt introduction and basics (30 minutes)

  • Lecture: sbt overview; verifying Java, Scala, and sbt installation; adding proxy information; adding memory arguments

Manually creating a project in sbt (30 minutes)

  • Lecture: Creating and editing build.sbt;adding proxy information; adding memory arguments
  • Hands-on exercise: Create a manual build

Break (10 minutes)

Automatically creating a project in sbt using Giter8 (15 minutes)

  • Lecture: Giter8 overview; using Giter8 to create a project in sbt
  • Hands-on exercise: Create a build using Giter8 templates

Bringing your project into your IDEs (25 minutes)

  • Lecture: Bringing an sbt project into Eclipse; bringing an sbt project into IntelliJ IDEA; bringing an sbt project into VS Code; bringing an sbt project into other editors
  • Hands-on exercise: Import your Giter8 project

Break (10 minutes)

Basic sbt commands (20 minutes)

  • Lecture: Running commands from the OS; running commands within sbt; common commands, such as cleaning, compiling, testing with ScalaTest
  • Hands-on exercise: Test your code

Basic sbt commands (10 minutes)

  • Lecture: More running commands from the OS; using REPL with classloading with Console
  • Hands-on exercise: Use Console

Other build tools (30 minutes)

  • Lecture: Scala with Maven; Scala with Gradle; Scala with Mill