Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Scala Programming Projects

You're reading from   Scala Programming Projects Build real-world projects using popular Scala frameworks such as Play, Akka, and Spark

Arrow left icon
Product type Paperback
Published in Sep 2018
Publisher Packt
ISBN-13 9781788397643
Length 398 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Mikael Valot Mikael Valot
Author Profile Icon Mikael Valot
Mikael Valot
Nicolas Jorand Nicolas Jorand
Author Profile Icon Nicolas Jorand
Nicolas Jorand
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Writing Your First Program FREE CHAPTER 2. Developing a Retirement Calculator 3. Handling Errors 4. Advanced Features 5. Type Classes 6. Online Shopping - Persistence 7. Online Shopping - REST API 8. Online Shopping - User Interface 9. Interactive Browser 10. Fetching and Persisting Bitcoin Market Data 11. Batch and Streaming Analytics 12. Other Books You May Enjoy

Using the basic features

In this section, and in the rest of this book, we will highlight some key shortcuts in italics. I strongly encourage you to use and remember these shortcuts. They save a tremendous amount of time and will keep you focused on the task at hand. If you cannot remember a shortcut, you can use the mother of all shortcuts, Ctrl + Shift + A (Windows/Linux) or cmd + shift + A (macOS), and type the name of the action you are looking for.

If you are using IntelliJ for the first time, I find it useful to display all tool buttons. Go to the View menu, and check Toolbar and Tool buttons.

SBT synchronization

Now, let's have a look at our build configuration. SBT (short for Simple Build Tool) is the de facto build tool in the Scala community. Double-click on build.sbt:

name := 'scala_fundamentals"

version := "0.1"

scalaVersion := "2.12.4"

This file describes how SBT will compile, test, and deploy our project. For now, it is fairly simple.

One important thing to keep in mind is that IntelliJ manages its own set of files to define a project structure. They are located in the .idea directory of your project.
Whenever you change build.sbt, IntelliJ has to interpret the changes and translate them.

For instance, If I change the Scala version to 2.12.3 and save (Ctrl + S or cmd + S), IntelliJ will propose to synchronize the changes or enable autoimport:

On a small project, it is ok to use autoimport, but on a large one, it can be a bit annoying. The synchronization can take time and it might kick off too often.

When you program in Scala using IntelliJ, you therefore have two ways of compiling your project:

  • SBT, in which case you would only use IntelliJ as an advanced text editor
  • IntelliJ

You could, in theory, mix and match: start building with SBT and continue with IntelliJ or the other way around. However, I strongly discourage you to do so, as you may get some unexpected compilation errors. When you want to switch to one tool or the other, it is best to clean all compiled files first.

We will further expand on SBT later in this book, but for now, we are only going to use IntelliJ's own build.

Build

The project has been created and ready to be built. The build process does the following:

  • Compiles the source files present at the source path and the test path
  • Copies any resource files needed in the output path
  • Reports any errors/warnings in the Message tool window

There are two ways to build the project:

  • If you want to build your project incrementally, go to Build | Build Project (Ctrl + F9 or cmd + F9)
  • If you want to delete all files and rebuild everything, go to Build | Rebuild All

As we do not have a source yet, the build is fast and no errors should appear in the Message tool window.

You have been reading a chapter from
Scala Programming Projects
Published in: Sep 2018
Publisher: Packt
ISBN-13: 9781788397643
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image