Search code examples
intellij-ideapluginssdkintellij-pluginintellij-scala

IntelliJ plugins vs SDKs


I've been using IntelliJ IDEA Community 2018.1 for a few months now, strictly with Java and Groovy projects. I just went to import my first (ever) Scala/Gradle project, and when it loaded, I noticed that the IDE wasn't really "loading" the Scala sources (compiling them, etc.). If I opened a Scala source file, it just appeared in the "text editor mode" and if I wrote a line of code that was a flagrant compiler error, IntelliJ didn't complain at all. I also noticed that if I went to create a New File, it didn't give me "Scala" as an option.

So I went into Preferences >> Plugins and installed the Scala plugin, and that made everything work perfectly fine.

However, I then noticed IntelliJ prompting me to configure the "Scala SDK", which I did, and everything is still working as it was when I had only installed the "Scala plugin".

So I ask: What is the difference between the IntelliJ Scala "plugin" and configuring the Scala "SDK"?


Solution

  • If you install the Scala plugin, then IntelliJ IDEA will understand that *.scala files are "Scala files" (otherwise plain text), and will provide basic features like syntax highlight.

    But that's just code editing, anyway you'll have your Scala files compiled, right? So you need a Scala SDK, and IntelliJ IDEA will use the SDK to compile your codes.
    Also, the Scala standard library is in the SDK. IntelliJ IDEA will read them and provides completions and goto definitions (otherwise you'll see unresolved reference errors everywhere).

    You can also use build tools, with build tools you don't have to configure the SDK in your IDE. IntelliJ IDEA will create SDK automatically by reading the configurations.