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.

http://www.lihaoyi.com/mill/

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?

I recently discovered that you can make InteliJ understand the emacs key bindings. This takes much of the pain out of editing. I don’t have to keep removing my hand from the keyboard every time I want to do simple navigation and editing.

I recently discovered (as I posted elsewhere) that you don’t have to spend hours making IntelliJ understand emacs key bindings (at least cursor navigation), because there is an Emacs setting for IntelliJ. :wink: It is not perfect, but it makes the editor much more pleasant to the touch typist. I don’t have to keep moving my hands to and away from the keyboard to do simple editing.

I’ve been using both the eclipse and the InteliJ development environment. I must say the eclipse is far and above the superior. The other is only as good as a C++ development tool. It’s not very good at Java.

I almost exclusively use eclipse. I’ve pretty much given up on the other environment. It is the one that the scala-lang site recommends. So there might be something I’m just missing. Other than a syntax friendly visual navigator & word processor in is no different that emacs plus sbt.

The most recent eclipse solves the problem with the popup help one gets after typing “.”. Unfortunately, the compiler doesn’t seem to work. Once the code is compiled, (most) all of the debugging works. I’ve been considering picking up maintenance of the eclipse plugin. I consider myself as a poor scala programmer. It isn’t close enough to other functional languages for me to pick up quickly. Though the syntax is easier than some of the other ones. I’ve never built a plug-in either.

1 Like

I’ve only got Visual Studio and Eclipse to compare with IntelliJ, but for me IntelliJ is by far the worst of the three. Some people seem to love it, I don’t know what I’m doing wrong. I use the embedded sbt terminal, nothing seems to work consistently or smoothly, I’ve tried the direct method of setting up a task, but that seems even less reliable. In Eclipse code completion, hover documentation, go to definition all just worked.