2013-01-24 66 views
4

如何根據每個項目更改SBT調試端口?每個項目的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 

回答

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 "[email protected]" | 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 
+0

尼斯。這不是什麼大問題,但是我通過不對sbt-launch.jar的路徑進行硬編碼來使它更通用一些。我用這個替換了SBT_LAUNCH =行:'SBT_LAUNCH = $(grep -oE'/ [^] + sbt-launch.jar'$(which sbt))' –