Skip to content

Commit

Permalink
Merge pull request #514 from iusildra/add--g-option
Browse files Browse the repository at this point in the history
added -g javac option & updated bin/scalafmt
  • Loading branch information
adpi2 authored Jul 18, 2023
2 parents 7ee08de + 7ab861f commit 78009cc
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ object DebugAdapterPlugin extends sbt.AutoPlugin {
def runSettings: Seq[Def.Setting[_]] = Seq(
startMainClassDebugSession := mainClassSessionTask.evaluated,
startRemoteDebugSession := remoteSessionTask.evaluated,
stopDebugSession := stopSessionTask.value
stopDebugSession := stopSessionTask.value,
Keys.compile / Keys.javacOptions := {
val jo = (Keys.compile / Keys.javacOptions).value
if (jo.exists(_.startsWith("-g"))) jo
else jo :+ "-g"
}
)

/**
Expand Down
37 changes: 37 additions & 0 deletions modules/sbt-plugin/src/sbt-test/debug-session/debug-java/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import ch.epfl.scala.debugadapter.testfmk._

val checkDebugJava = inputKey[Unit]("Check that the -g option has been added")

def checkDebugJavaTask = Def.inputTask {
val uri = (Compile / startMainClassDebugSession).evaluated
val source = (Compile / sources).value.head.toPath
implicit val context: TestingContext = TestingContext(source, "3.3.0")
DebugTest.check(uri)(Breakpoint(source, 6), Evaluation.success("x", 1))
}
def checkDebugJavaWithGSpecializedTask = Def.inputTask {
val uri = (Compile / startMainClassDebugSession).evaluated
val source = (Compile / sources).value.head.toPath
implicit val context: TestingContext = TestingContext(source, "3.3.0")
DebugTest.check(uri)(Breakpoint(source, 6), Evaluation.failed("x"))
}

lazy val debugJavaWithG =
project
.in(file("./withG"))
.settings(
javacOptions += "-g",
checkDebugJava := checkDebugJavaTask.evaluated
)

lazy val debugJavaWithoutG =
project
.in(file("./withoutG"))
.settings(checkDebugJava := checkDebugJavaTask.evaluated)

lazy val debugJavaWithGSpecialized =
project
.in(file("./withGSpecialized"))
.settings(
javacOptions += "-g:lines,source",
checkDebugJava := checkDebugJavaWithGSpecializedTask.evaluated
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
val pluginVersion = sys.props
.get("plugin.version")
.getOrElse {
sys.error(
"""|The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -D.
|""".stripMargin
)
}

addSbtPlugin("ch.epfl.scala" % "sbt-debug-adapter" % pluginVersion)
libraryDependencies += "ch.epfl.scala" %% "scala-debug-adapter-test" % pluginVersion
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// required for adopt@1.8
addSbtPlugin("org.scala-debugger" % "sbt-jdi-tools" % "1.1.1")
3 changes: 3 additions & 0 deletions modules/sbt-plugin/src/sbt-test/debug-session/debug-java/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
> 'debugJavaWithG / checkDebugJava {"class":"example.Main","arguments":[],"jvmOptions":[]}'
> 'debugJavaWithoutG / checkDebugJava {"class":"example.Main","arguments":[],"jvmOptions":[]}'
> 'debugJavaWithGSpecialized / checkDebugJava {"class":"example.Main","arguments":[],"jvmOptions":[]}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package example;

public class Main {
public static void main(String[] args) {
int x = 1;
System.out.println("Hello, world!");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package example;

public class Main {
public static void main(String[] args) {
int x = 1;
System.out.println("Hello, world!");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package example;

public class Main {
public static void main(String[] args) {
int x = 1;
System.out.println("Hello, world!");
}
}

0 comments on commit 78009cc

Please sign in to comment.