KajMagnus
KajMagnus

Reputation: 11666

How make Intellij Idea debug a Play 2.1 app's source code files, instead of project definition only

When I create a new Play 2.1 project, Intellij Idea insists on debugging the project configuration files only. That is, lines in ./project/Build.scala, and no other files.

How do I tell Idea to debug stuff in ./app/ instead?

I've generated Idea project files like so: [project-name] $ idea with-sources=yes (in Play's console).

(I cannot remember this ever happening before with Play 2.0 or earlier versions of 2.1)

Upvotes: 4

Views: 689

Answers (2)

Aaron Patzer
Aaron Patzer

Reputation: 11

I'm running Intellij, with remote debug on port 9999 1. ~apatzer> play debug 2. Then start my Remote configuration in Intellij 3. [playproject] $ run ==> Successful at hitting breakpoints and debugging.

Because of forking, I was unable to hit breakpoints in any of my tests. For example: [playproject] $ test-only com.mydomain.pkg.MyTest ==> FAIL different process. Breakpoints not hit in IDE.

Here's what worked:

import sbt._
import Keys._
import play.Project._

object MyBuild extends Build {
...
lazy val main = play.Project(appName, appVersion, appDependencies).settings(
  Keys.fork in testOnly := false,
  libraryDependencies ++= deps,
  ...

Upvotes: 0

KajMagnus
KajMagnus

Reputation: 11666

There were 2 causes for this issue: one "interesting" and one stupid.

The interesting cause:

Play 2.1 and SBT seems to fork tests (and thus run them in a separate process). Therefore breakpoints in my unit test code were never hit.

One way to "fix" this, is to add this config settinig:

Keys.fork in Test := false

The stupid cause:

I had not yet compiled any "real" source code files in the new project. So therefore Idea never activated breakpoints on those lines. But the project configuration Build.scala file was compiled when I launched Play's SBT console I think, so Idea activated breakpoints in Build.scala directly. — So there was never a problem really: I just had to hit run in the Play console and then the breakpoints came alive (after Play had compiled my sources).

Upvotes: 3

Related Questions