stevedlawrence commented on code in PR #130:
URL: https://github.com/apache/daffodil-sbt/pull/130#discussion_r2402899576
##########
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:
Good to know. It should really only happen if people are using real old
versions of Daffodil or overriding the scalaVersion set by the plugin, but it's
worth handling just in case. I'll add a case and a test to ensure old versions
still work.
--
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]