2014-02-12 59 views

回答

4

Specifying flywayUrl through system property in SBT應該有一定的幫助。

以下內容添加到build.sbt

lazy val isDebugging = settingKey[Boolean]("true when xdebug is true; false otherwise") 

isDebugging := System.getProperty("xdebug") == "true" 

fork in Test := !isDebugging.value 

當你執行sbt -Dxdebug=true它給你想要的東西。

順便說一句我沒有在SBT源代碼中看到jvm-debug的引用,但它確實在我用來啓動它的shell腳本中。如果設置-Xdebug,則可能需要更改sbt-launch-lib.bash以適應添加xdebug的更改。

+1

JVM調試: *文檔:https://github.com/paulp/sbt-extras/blob/6930c304284a897c33e7e6bdd77e0a4812f6698e/sbt#L291 * IMPL:https://github.com/paulp/sbt-extras/ blob/6930c304284a897c33e7e6bdd77e0a4812f6698e/sbt#L153-L156 –

+0

這不適合我。我使用了System.getEnv(「usedebug」)==「true」,並在我的.bashrc中添加了一個別名sbtd =「usedebug = true sbt -jvm-debug 5005」'''以啓動調試器並擁有env set,現在當我使用該命令時它不會分叉 – elmalto

+0

檢查'sbt -Dusedebug = true'是否可以工作。 –

2

Jacek的建議是指向正確的方向,但不能爲我工作(甚至根本不?)。 System.getProperty無法檢索由sbt的Bash腳本基本設置的-Xdebug標誌 - 當調用System.getProperties時,-Xdebug未在那裏列出,同樣也包含任何其他非標準JVM屬性(例如-Xmx)。

什麼工作對我來說是這樣的:

lazy val isDebug = settingKey[Boolean]("true when -Xdebug is set, false otherwise") 

isDebug := ManagementFactory.getRuntimeMXBean.getInputArguments.contains("-Xdebug") 

fork in Test := !isDebug.value 

乾杯!

相關問題