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

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.

主站蜘蛛池模板: 泰安市| 泰和县| 海口市| 缙云县| 南通市| 乌鲁木齐县| 台中县| 平舆县| 文成县| 庄浪县| 永城市| 鄂托克旗| 丰顺县| 拜城县| 进贤县| 利川市| 新泰市| 梅州市| 邮箱| 灵川县| 桦南县| 烟台市| 呈贡县| 安福县| 宜黄县| 乐安县| 富民县| 内江市| 沁水县| 公主岭市| 漠河县| 新丰县| 噶尔县| 成都市| 连平县| 长岭县| 大同市| 临洮县| 遂溪县| 石河子市| 城口县|