Skip to content

Instantly share code, notes, and snippets.

@hrhino
Created November 4, 2019 21:49
Show Gist options
  • Save hrhino/fc8abd48b04dce0a38caf72339ff1aa5 to your computer and use it in GitHub Desktop.
Save hrhino/fc8abd48b04dce0a38caf72339ff1aa5 to your computer and use it in GitHub Desktop.
commands for enabling / disabling java debugger in scala/scala
package scala.build
import sbt._, Keys._, plugins._
object Debug extends AutoPlugin {
override def requires = JvmPlugin
override def trigger = allRequirements
import VersionUtil._
override def globalSettings: Seq[Def.Setting[_]] = {
def enableDebugger(suspend: Boolean) =
s"-agentlib:jdwp=transport=dt_socket,server=y,suspend=${if (suspend) "y" else "n"},address=5005"
def commandPair(name: String, scope: String, suspend: Boolean): List[Command] = {
List(name + "On" -> "+=", name + "Off" -> "-=") map { case (cmd, op) =>
Command.command(cmd)(s"""set javaOptions in $scope $op "${enableDebugger(suspend)}" """ :: _)
}
}
val repl = if (versionProps("starr.version") startsWith "2.13") "replFrontend" else "replJlineEmbedded"
List(
commands ++= commandPair("replDebug", s"run in $repl", suspend = false),
commands ++= commandPair("partestDebug", "test in IntegrationTest", suspend = true ),
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment