官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 广丰县| 浏阳市| 邢台市| 绍兴市| 马龙县| 盈江县| 清苑县| 芒康县| 广宗县| 武隆县| 文登市| 虹口区| 收藏| 西畴县| 普陀区| 噶尔县| 吴旗县| 南通市| 富川| 盱眙县| 类乌齐县| 横峰县| 威海市| 兴义市| 密云县| 湖口县| 大名县| 千阳县| 四子王旗| 石屏县| 蒲城县| 丰原市| 岚皋县| 崇文区| 司法| 新竹市| 阿勒泰市| 湾仔区| 图们市| 祁门县| 桦南县|