如何基于每个项目更改SBT调试端口?
我可以将调试JVM选项添加到环境变量SBT_OPTS
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
但这将适用于所有SBT实例,如果我想同时在两个单独项目的调试中运行SBT,我会收到此错误,因为该端口已在使用中:
ERROR: transport error 202: bind failed: Address already in use
答案 0 :(得分:5)
通过自制软件修改sbt附带的sbt脚本,我创建了这个脚本,让你启动sbt并指定调试端口,如下所示:
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