diff --git a/project/Build.scala b/project/Build.scala index 4cda2cda5135..0764c1f787ad 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -1437,6 +1437,9 @@ object Build { // Needed so that the library sources are visible when `dotty.tools.dotc.core.Definitions#init` is called "-sourcepath", (Compile / sourceDirectories).value.map(_.getCanonicalPath).distinct.mkString(File.pathSeparator), ), + // Make sure that the produced artifacts have the minimum JVM version in the bytecode + Compile / javacOptions ++= Seq("--target", Versions.minimumJVMVersion), + Compile / scalacOptions ++= Seq("--java-output-version", Versions.minimumJVMVersion), // Only publish compilation artifacts, no test artifacts Compile / publishArtifact := true, Test / publishArtifact := false, @@ -1467,6 +1470,9 @@ object Build { // Needed so that the library sources are visible when `dotty.tools.dotc.core.Definitions#init` is called "-sourcepath", (Compile / sourceDirectories).value.map(_.getCanonicalPath).distinct.mkString(File.pathSeparator), ), + // Make sure that the produced artifacts have the minimum JVM version in the bytecode + Compile / javacOptions ++= Seq("--target", Versions.minimumJVMVersion), + Compile / scalacOptions ++= Seq("--java-output-version", Versions.minimumJVMVersion), // Only publish compilation artifacts, no test artifacts Compile / publishArtifact := true, Test / publishArtifact := false, diff --git a/project/Versions.scala b/project/Versions.scala new file mode 100644 index 000000000000..3fba907e9d68 --- /dev/null +++ b/project/Versions.scala @@ -0,0 +1,6 @@ +object Versions { + + /* The Minimum JVM version the artifact should be able to use */ + val minimumJVMVersion = "17" + +}