Using IntelliJ with scala


What does the SBT plugin actually provide? If I need to run an sbt command, I open the terminal in Intellij and enter in the sbt command.


You mean dependency resolver, not dependent revolver. The latter is a loaded gun that could go off at any time - which I guess can describe some of my first Scala code. :slight_smile:


sbt isn’t a plugin but it does take plugins. It is a standalone build tool that is to me the definitive word on the Scala compiler. There is nothing between your code and the compiler. I know it may not make a difference unless code gets really complicated, but that can often happen when writing the first draft of some code. For me it is a more logical layout of the dependencies and then some additional stuff when you become an intermediate user - like better handling of io configs (for me) and Twirl imports for instance.


SBT plugin for IDEA helps it find out about the project structure. Same as Maven (only the Maven plugin comes bundled with IDEA).
IDEA needs to know about subprojects, their inter-dependencies, locations of source files, resources, test directories, classpaths etc. All this info is then used to provide that intelligent IDE functionality.

Please take note that there used to be a separate SBT plugin. It is still visible in the plugin repositories but don’t use that, you’ll confuse yourself and the IDE. Everything is now bundled in the Scala plugin.This is all you need.


Actually … maven is quite simple doing large multi project builds.


I think I will investigate SBT … It is , afterall, the original tool used to build scala applications. The only reason I use maven is because I know maven and it seems so simple and easy to use ; at least right now with my simple beginner programs. I was just assuming that it would be just as simple to build complex , multi project code that utilized stuff from internal artifactories and did all types of stuff. With Java, such things are very simple.


There’s also Mill, which I’m using on one project and quite like.


Yes, you need the selected directory to be recognized by IDEA as a source directory for the worksheet to be available.


I teach a course using Scala and I “strongly suggest” students use IntelliJ IDEA. For most of them, it’s their first use of an IDE and it usually goes pretty smoothly. Just open a directory with an sbt file using IDEA and everything is set up (dependencies, source directories, etc.). The IDE runs Scalatest suites with a simple click and offer other niceties that are useful to beginners (completion, desugarization, etc.)

There is the occasional quirk, but nothing too bad. IDEA seemed to have worked better with sbt 0.13 than with sbt 1, but it should get better with time.

As a side note, I was a long time emacs user who could never make the switch to an IDE. Eclipse, in particular, drives me crazy. I was firmly in the “editor, not IDE” camp for years. I started to use IntelliJ IDEA to get the Scala worksheets, which I use in class extensively. I liked IDEA and began to use it more and more. I now use it with Scala, Java, Python, JavaScript, bash and markdown. I’ve ditched emacs after 20+ years of good service.


I apologize sincerely for playing the grammarian, because as tempting as I find the prescriptivist position, I know one must be a descriptivist, which is to say, a scientist.

But it’s sbt in lower case and it doesn’t stand for anything. It’s not an acronym, it doesn’t mean “spit”, as I once assumed, or anything else. I’m not an sbt apologist; I don’t understand the code base and technically, I don’t even use sbt, at work we use gradle. Is it gradle or gradel like dreidel?

I do think that, by any measure, sbt is an interesting endeavor, like scala itself, and worth investigating just on those terms.

With Java, such things are very simple.

Um, as it were, I think it’s fair to say nothing is simpler in Java, compared to Scala. One can argue that Java is hot on the heels of Scala in recent releases, in terms of some syntaxes and expressiveness. But in terms of, should I let my company send me to Scala World this year or to Java specialist training on Crete? I think the answer is clearly that you must make both pilgrimages.

I just noticed that pilgrimage is pilgr + image. Why is that so funny?