Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't debug a Scala application in IntelliJ + sbt-idea-plugin

I'm developing a Scala application using IntelliJ Idea 12, sbt and sbt-idea plugin. I generated all necessary files by saying "gen-idea" and everything goes well -- I was able to compile the sources in command line in sbt as well in IntelliJ Idea 12 itself using menu Build->Make Project.

Here is my main class (Application.scala)

object Application extends App {
  val a = 12345
  println("application entry point 1235")
}

I have a breakpoint at val a = 12345.

1) There were other errors before, but now says "Module is not specified". How do I solve this?

I'll be posting updates since there would be other errors as my gut tells me.

like image 368
Alan Coromano Avatar asked Jul 02 '13 05:07

Alan Coromano


People also ask

How do I debug an application 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.

How do I get Scala plugin in IntelliJ?

To install Scala plugin, press Ctrl+Alt+S , open the Plugins page, browse repositories to locate the Scala plugin, click Install and restart IntelliJ IDEA. Now you can successfully check out from VCS, create, or import Scala projects.

How do I run a Scala program in IntelliJ?

In Project Structure -> Modules click on the module you want to compile in scala and click the plus icon above and select Scala. Again be sure to select a compiler library. If you want to, setup configurations for the compiler under the facet.


1 Answers

To debug just like to run, you need to create a run configuration (menu Run -> Edit Configurations). If you haven't done yet, you need to add an Application entry with the + button.

Not only do you need to specify the main class, but also which "module" that class belongs to. By default, "Use classpath of module" will be empty. Here in the popup menu, you need to select the main module (not the one ending in "-build"). After you choose that and close with "Ok", it should work.

enter image description here


Although not necessary, I also recommend to use sbt for building instead of "Make". In the configuration in the "Before launch" part, select "Make" and click on "-", then click on "+" and choose sbt -> test:products.

Edit: Here is the reference for the SBT plugin for IntelliJ.

like image 68
0__ Avatar answered Sep 27 '22 20:09

0__