shanedell commented on code in PR #130:
URL: https://github.com/apache/daffodil-sbt/pull/130#discussion_r2402738117
##########
src/main/scala/org/apache/daffodil/DaffodilPlugin.scala:
##########
@@ -359,6 +359,51 @@ object DaffodilPlugin extends AutoPlugin {
}
},
+ /**
+ * If we are building plugins, we want to make sure they are built with
compatability for
+ * the minimum version of Java that daffodilVersion supports, regardless
of the javac
+ * version used for compilation. For example, even when building on Java
17+, we want to
+ * make sure plugins that are built for Daffodil 3.10.0 are built with
Java 8 compatability.
+ * We use daffodilVerison to determine the target JDK version, and the
current javac version
+ * to figure out the right javacOptions to set.
+ */
+ javacOptions ++= {
+ if (daffodilBuildsPlugin.value) {
+ val daffodilPluginJdkCompatMap = Map(
+ ">=4.0.0 " -> "17",
+ "<=3.11.0" -> "8"
+ )
+ val jdkCompat = filterVersions(daffodilVersion.value,
daffodilPluginJdkCompatMap).head
+ val javacOptionsMap = Map(
+ ">=9" -> Seq("--release", jdkCompat),
+ " =8" -> Seq("-source", jdkCompat, "-target", jdkCompat)
+ )
+ filterVersions(Properties.javaSpecVersion, javacOptionsMap).head
+ } else {
+ Seq()
+ }
+ },
+
+ /**
+ * See javacOptions above for details
+ */
+ scalacOptions ++= {
+ if (daffodilBuildsPlugin.value) {
+ val daffodilPluginJdkCompatMap = Map(
+ ">=4.0.0 " -> "17",
+ "<=3.11.0" -> "8"
+ )
+ val jdkCompat = filterVersions(daffodilVersion.value,
daffodilPluginJdkCompatMap).head
+ val scalacOptionsMap = Map(
+ ">=2.13" -> Seq("--release", jdkCompat),
+ "<=2.12" -> Seq(s"--target:jvm-$jdkCompat")
Review Comment:
Not sure how necessary this is. But in my testing of trying to do this with
the `daffodil-vscode` debugger, I noticed that certain versions of Scala 2.12
don't support this `--target` flag. They would only support `-target` and only
allowed values of `jvm-1.5, jvm-1.6, jvm-1.7, jvm-1.8`. Scala versions <=
2.12.16 don't support `--target` and Scala versions > 2.12.16 do support
`--target`.
--
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]