stevedlawrence commented on code in PR #1452:
URL: https://github.com/apache/daffodil-vscode/pull/1452#discussion_r2414255846


##########
build.sbt:
##########
@@ -221,3 +183,122 @@ lazy val xjcSettings =
       cachedFun(Set(daffodilLibJar)).toSeq
     }
   )
+
+lazy val `daffodil-debugger` = project
+  .in(file("."))
+  .settings(commonSettings, ratSettings)
+  .settings(publish / skip := true)
+  .aggregate(debuggers.projectRefs: _*)
+
+/** Since using projectMatrix, there will be a debugger, debugger2_12 and 
debugger3 target. The debugger target is for
+  * Daffodil 3.11.0 and Scala 2.13. The debugger2_12 target is for Daffodil 
3.10.0 and Scala 2.12. The debugger3 target
+  * is for Daffodil 4.0.0 and Scala 3. (only availabe when using JDK 17+)
+  *
+  * When running something like "sbt test" that will run all targets. To use a 
single target do one of: sbt
+  * debugger/test OR sbt debugger2_12/test OR sbt debugger3/test. Based on 
which version of the debugger you are
+  * targeting.
+  */
+lazy val debuggers = {
+  val debugger = (projectMatrix in (file("debugger")))
+    .enablePlugins(BuildInfoPlugin, JavaAppPackaging, UniversalPlugin, 
ClasspathJarPlugin, SbtXjcPlugin)
+    .settings(commonSettings)
+    .settings(xjcSettings)
+    .settings(
+      name := "daffodil-debugger",
+      scalacOptions ++= buildScalacOptions(scalaVersion.value),
+      javacOptions ++= buildJavacOptions(scalaVersion.value),
+      libraryDependencies ++= Seq(
+        /* NOTE: To support Java 8:
+         *  logback-classic can not go above version 1.2.11.
+         *  com.microsoft.java.debug.core can not go above version 0.34.0.
+         *  jansi can not go above version 1.18.
+         */
+        // scala-steward:off
+        "ch.qos.logback" % "logback-classic" % "1.2.11",
+        "com.microsoft.java" % "com.microsoft.java.debug.core" % "0.34.0",
+        "org.fusesource.jansi" % "jansi" % "1.18",
+        // scala-steward:on
+        "co.fs2" %% "fs2-io" % "3.12.0",
+        "com.monovore" %% "decline-effect" % "2.5.0",
+        "org.typelevel" %% "log4cats-slf4j" % "2.7.1",
+        "org.scalameta" %% "munit" % "1.1.1" % Test
+      ),
+      buildInfoPackage := "org.apache.daffodil.debugger.dap",
+      buildInfoKeys := Seq[BuildInfoKey](
+        name,
+        version,
+        scalaVersion,
+        sbtVersion,
+        "daffodilVersion" -> getDaffodilVersion(scalaVersion.value)
+      ),
+      packageName := s"${name.value}-${getDaffodilVersion(scalaVersion.value)}"
+    )
+    .jvmPlatform(
+      scalaVersions = Seq("2.12.20"),
+      settings = Seq(
+        libraryDependencies ++= 
getPlatformSpecificLibraries(scalaVersion.value)
+      )
+    )
+    .jvmPlatform(
+      scalaVersions = Seq("2.13.16"),
+      settings = Seq(
+        libraryDependencies ++= 
getPlatformSpecificLibraries(scalaVersion.value)
+      )
+    )
+
+  if (scala.util.Properties.isJavaAtLeast("17"))
+    debugger.jvmPlatform(
+      scalaVersions = Seq("3.3.6"),
+      settings = Seq(
+        libraryDependencies ++= 
getPlatformSpecificLibraries(scalaVersion.value)
+      )
+    )
+  else debugger
+}
+
+def getPlatformSpecificLibraries(scalaVersion: String) = {
+  val daffodilVersion = getDaffodilVersion(scalaVersion)
+
+  if (scalaVersion.startsWith("3"))
+    Seq("org.apache.daffodil" %% "daffodil-core" % daffodilVersion)
+  else
+    Seq(
+      "org.apache.daffodil" %% "daffodil-sapi" % daffodilVersion,
+      "org.apache.daffodil" %% "daffodil-runtime1" % daffodilVersion,
+      "org.apache.daffodil" %% "daffodil-lib" % daffodilVersion % Test
+    )

Review Comment:
   Ah I think that makes sense. We wouldn't remove these dependencies, just 
mark them as "provided" dependencies. I think they might also need to be added 
to the "test" config since I don't think "provided" dependencies are available 
when testing, which I assume is needed. I think something like this would do it:
    
   ```scala
     if (scalaVersion.startsWith("3"))
       Seq("org.apache.daffodil" %% "daffodil-core" % daffodilVersion % 
"provided,test")
     else
       Seq(
         "org.apache.daffodil" %% "daffodil-sapi" % daffodilVersion % 
"provided,test",
         "org.apache.daffodil" %% "daffodil-runtime1" % daffodilVersion % 
"provided,test",
         "org.apache.daffodil" %% "daffodil-lib" % daffodilVersion % 
"provided,test"
   )
   ```
   
   This makes it so the daffodil jars--including their transitive 
dependencies--are available during compilation and testing, but the "provided" 
makes it so they are ignored when they are assembled (I think by 
sbt-navtive-packager?)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to