How can I enable remote debugging for SBT in windo

2019-02-03 08:48发布

I would like to accomplish running the equivalent of this

sbt -jvm-debug 5005

However I don't seem to be able to pass in args in Windows. This is what I am seeing

>sbt -jvm-debug 5005
[info] Loading project definition from [myProject]
[info] Set current project to [myProject] (in build file myProject)
[error] Expected letter
[error] Expected symbol
[error] Expected '!'
[error] Expected '+'
[error] Expected '++'
[error] Expected ';'
[error] Expected end of input.
[error] Expected 'show'
[error] Expected '*'
[error] Expected '{'
[error] Expected project ID
[error] Expected configuration
[error] Expected key
[error] 5005
[error] ^
[error] Not a valid command: jvm-debug
[error] Not a valid project ID: jvm-debug
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: jvm-debug
[error] jvm-debug
[error]          ^                  

I would like to be able to remote debug this application from Intellij. Any help would be great!

2条回答
太酷不给撩
2楼-- · 2019-02-03 09:04
set SBT_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
sbt run

was the only working solution on Windows 7.

查看更多
干净又极端
3楼-- · 2019-02-03 09:15

Seems like the Windows version of SBT doesn't define this functionality.

On Linux it is defined in the $SBT_HOME/sbt/bin/sbt-launch-lib.bash as

addDebugger () {   
  addJava "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1" 
}

You can achieve the same result by setting the SBT_OPTS environmental variable on Windows.

Run SBT like this, to make the debugger listen on port 5005

set SBT_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005" && sbt
查看更多
登录 后发表回答