David
David

Reputation: 2399

Run sbt project in debug mode with a custom configuration

I want to introduce a debug mode in my sbt 0.11 project using a special configuration. I've tried to implement this using the following code but unfortunately, it doesn't seems to work as expected. I'm launching debug:run but the run doesn't suspends as expected.

object Test extends Build {
  lazy val root = Project("test", file("."))
    .configs( RunDebug )
    .settings( inConfig(RunDebug)(Defaults.configTasks):_*)
    .settings(
      name := "test debug",
      scalaVersion := "2.9.1",
      javaOptions in RunDebug += "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005",
      fork in RunDebug := true
    )

  lazy val RunDebug = config("debug").extend( Runtime )
}

Upvotes: 9

Views: 5804

Answers (3)

Sameer
Sameer

Reputation: 511

for simply running sbt project in debug mode , just do

JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005

and then

sbt run would run SBT in debug mode, you can create a remote debug configuration in eclipse and connect to it. this is a rather lame, but useful when you have a multi module play project and want to run one of the modules in the debug mode

Upvotes: 3

Allen Chou
Allen Chou

Reputation: 1237

In Intellij IDEA, I just boot the program in Dedug mode and it seems to work properly without further configuration.

Upvotes: -1

David
David

Reputation: 2399

Ok that works with the following :

object Test extends Build {
  lazy val root = Project("test", file("."))
    .configs( RunDebug )
    .settings( inConfig(RunDebug)(Defaults.configTasks):_*)
    .settings(
      name := "test debug",
      scalaVersion := "2.9.1",
      javaOptions in RunDebug ++= Seq("-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
      fork in RunDebug := true
    )

  lazy val RunDebug = config("debug").extend( Runtime )
}

now I can run my code in debug mode using debug:mode.

Upvotes: 7

Related Questions