Reputation: 14380
How do I change the SBT debug port on a per project basis?
I can add the debug JVM options to the environment variable SBT_OPTS
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
But this will apply to all SBT instances and if I want to run SBT in debug for two separate projects simultaneously, I get this error because the port is already in use:
ERROR: transport error 202: bind failed: Address already in use
Upvotes: 4
Views: 1561
Reputation: 14380
Modifying the sbt script that came with sbt via homebrew, I made this script that lets you start sbt and specify the debug port like so:
sbt-debug 5005
https://gist.github.com/4625742
#!/bin/sh
test -f ~/.sbtconfig && . ~/.sbtconfig
SBT_LAUNCH=/usr/local/Cellar/sbt/0.12.1/libexec/sbt-launch.jar
# Take leading integer as debug port and not sbt args
DEBUG_PORT=$1
SBT_ARGS=`echo "$@" | grep -oE "[^0-9].*"`
exec java -Xmx512M -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=${DEBUG_PORT} ${SBT_OPTS} -jar $SBT_LAUNCH $SBT_ARGS
Upvotes: 5