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.