Hi Ed!
This can be addressed by using a built-in Java MX bean:
val debugInUse = SettingKey[Boolean]("debug-in-use", "debug is used”)
debugInUse := {
val jvmOpts = java.lang.management.ManagementFactory.getRuntimeMXBean.getInputArguments
println("jvmOpts = " + jvmOpts)
jvmOpts contains "-Xdebug"
}
Output:
jvmOpts = [-Dfile.encoding=UTF8, -Xms512m, ..., -Xdebug, -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005]
> debug-in-use
[info] true
I didn’t see a setting key in sbt itself that would expose this list, javaOptions
available are for forked jvms, which brings me to the idea:
you could explore passing through the debug options (if present) to the javaOptions
for the forked jvms (on another port then).
more info on this here: http://www.scala-sbt.org/release/docs/Detailed-Topics/Forking.html#forked-jvm-options
Not sure what better suits your use-case. I hope this helps :-)