Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging SBT project with Play in IntelliJ IDEA

I have a SBT project

in this project i have a sub play project and other projects

example from my build file :

 lazy val subProj1 = Project(id = "sub-proj-1", base = file("sub1"))
.settings(...)...

 lazy val subProjPlay =  play.Project("play-proj", 1.0 , path = file("web"))

need to debug the play server from IntelliJ IDEA.

To run the project I use sbt run on the command line.

How can I debug the project in IDEA?

like image 752
The Best Avatar asked Mar 05 '14 10:03

The Best


3 Answers

I found this to be the easiest solution : (using IntelliJ IDEA )

in IntelliJ :

Go to "edit run configurations"

enter image description here

Create a new remote configuration (port 9999, all other details leave with default values)

enter image description here

Go back to IntelliJ and run the new debug configuration (don't forget to put a break point)

From command line run :

 sbt -jvm-debug 9999 run
like image 92
Nimrod007 Avatar answered Nov 10 '22 20:11

Nimrod007


The easiest solution.

  1. Edit Configurations... -> add SBT Task (not Remote task). Specify SBT Task: ~run.

  2. Run created SBT Task using - Debug Debug button

like image 11
Yuriy Tumakha Avatar answered Nov 10 '22 21:11

Yuriy Tumakha


Provided you've Play distribution installed locally, use play debug run on the command line and connect to localhost on the port 9999 in IDEA.

From Debugging section in Using the Play console in the official Play 2.2.x documentation:

You can ask Play to start a JPDA debug port when starting the console. You can then connect using Java debugger. Use the play debug command to do that

If however you don't have it (and for a reason don't want to install it), add Remote Run configuration in IDEA that will give you a hint for the command line arguments you should be using when launching SBT, e.g.

-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005

When you launch SBT that may or may not be as simple as launching SBT jar, just use the above to configure JVM to run in debug mode.

like image 2
Jacek Laskowski Avatar answered Nov 10 '22 21:11

Jacek Laskowski