Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging a Scala project (IntelliJ Idea 12 and sbt)

I've seen a few articles describing how to debug Scala applications, but nevertheless I want to ask it again due to the reason that all those articles are outdated and all things change very quickly in Scala world.

I use IntelliJ Idea 12 + sbt (not a plugin, a plugin doesn't work for some reason).

So how do I do that nowadays?

like image 488
Alan Coromano Avatar asked Jun 28 '13 02:06

Alan Coromano


People also ask

How add sbt to IntelliJ?

To enable that, we need to go into our project preferences and specify that behavior. Note checkboxes next to the label, “Use sbt shell”. Enable “for imports” and “for builds” and then click “OK”. This will cause IntelliJ to run an instance of SBT to both build and to manage project dependencies.

How do I enable debugging in IntelliJ?

Run the program in debug modeClick the Run icon in the gutter, then select Modify Run Configuration. Enter arguments in the Program arguments field. Click the Run button near the main method. From the menu, select Debug.


1 Answers

IMO, you are best off keeping SBT and Intellij separate, as they are two different concerns. One is for building, and the other is for developing.

Here are the steps that I typically go through to get a solid Scala/Intellij development environment up and running for a new Scala project.

  • Step 1: Install Scala Intellij Plugin
  • Step 2: Create a simple sbt project - details here
  • Step 3: Add the fantastic sbt-idea plugin to your sbt config
  • Step 4: sbt gen-idea
  • Step 5: Open project in Intellij 12
  • Enjoy debugging, syntax highlighting, code assist and all of the other nice IJ features.

On the sbt side, I typically keep a terminal open, with sbt running so that I can rapidly test things outside the context of Intellij.

HTH

like image 112
Steven Levine Avatar answered Oct 03 '22 13:10

Steven Levine