2018-07-02 16:38:07 +02:00
|
|
|
/*
|
2021-01-08 17:55:38 +01:00
|
|
|
* Copyright (C) 2017-2021 Lightbend Inc. <https://www.lightbend.com>
|
2018-07-02 16:38:07 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package akka
|
|
|
|
|
|
|
|
|
|
import sbt._
|
|
|
|
|
import sbt.Keys._
|
|
|
|
|
|
|
|
|
|
object Jdk9 extends AutoPlugin {
|
2019-10-03 05:02:40 +02:00
|
|
|
import JdkOptions.notOnJdk8
|
2018-07-02 16:38:07 +02:00
|
|
|
|
2019-12-05 16:40:05 +01:00
|
|
|
val CompileJdk9 = config("CompileJdk9").extend(Compile)
|
|
|
|
|
|
2019-12-16 11:45:13 +01:00
|
|
|
val TestJdk9 = config("TestJdk9").extend(Test).extend(CompileJdk9)
|
2018-07-02 16:38:07 +02:00
|
|
|
|
2019-01-15 20:35:53 +08:00
|
|
|
val SCALA_SOURCE_DIRECTORY = "scala-jdk-9"
|
|
|
|
|
val SCALA_TEST_SOURCE_DIRECTORY = "scala-jdk9-only"
|
|
|
|
|
val JAVA_SOURCE_DIRECTORY = "java-jdk-9"
|
|
|
|
|
val JAVA_TEST_SOURCE_DIRECTORY = "java-jdk9-only"
|
2019-04-16 00:10:42 -07:00
|
|
|
|
2018-07-02 16:38:07 +02:00
|
|
|
val compileJdk9Settings = Seq(
|
|
|
|
|
// following the scala-2.12, scala-sbt-1.0, ... convention
|
2019-04-16 00:10:42 -07:00
|
|
|
unmanagedSourceDirectories := notOnJdk8(
|
2019-12-16 11:45:13 +01:00
|
|
|
Seq(
|
|
|
|
|
(Compile / sourceDirectory).value / SCALA_SOURCE_DIRECTORY,
|
|
|
|
|
(Compile / sourceDirectory).value / JAVA_SOURCE_DIRECTORY)),
|
2019-04-19 07:53:27 +01:00
|
|
|
scalacOptions := AkkaBuild.DefaultScalacOptions ++ notOnJdk8(Seq("-release", "11")),
|
|
|
|
|
javacOptions := AkkaBuild.DefaultJavacOptions ++ notOnJdk8(Seq("--release", "11")))
|
2018-07-02 16:38:07 +02:00
|
|
|
|
2019-12-05 16:40:05 +01:00
|
|
|
val testJdk9Settings = Seq(
|
|
|
|
|
// following the scala-2.12, scala-sbt-1.0, ... convention
|
|
|
|
|
unmanagedSourceDirectories := notOnJdk8(
|
2019-12-16 11:45:13 +01:00
|
|
|
Seq(
|
|
|
|
|
(Test / sourceDirectory).value / SCALA_TEST_SOURCE_DIRECTORY,
|
|
|
|
|
(Test / sourceDirectory).value / JAVA_TEST_SOURCE_DIRECTORY)),
|
2019-12-05 16:40:05 +01:00
|
|
|
scalacOptions := AkkaBuild.DefaultScalacOptions ++ notOnJdk8(Seq("-release", "11")),
|
|
|
|
|
javacOptions := AkkaBuild.DefaultJavacOptions ++ notOnJdk8(Seq("--release", "11")),
|
2019-12-16 11:45:13 +01:00
|
|
|
compile := compile.dependsOn(CompileJdk9 / compile).value,
|
2019-12-05 16:40:05 +01:00
|
|
|
classpathConfiguration := TestJdk9,
|
2021-05-25 12:50:51 +02:00
|
|
|
externalDependencyClasspath := (Test / externalDependencyClasspath).value)
|
2019-12-05 16:40:05 +01:00
|
|
|
|
2018-07-02 16:38:07 +02:00
|
|
|
val compileSettings = Seq(
|
2018-07-11 15:37:47 +02:00
|
|
|
// It might have been more 'neat' to add the jdk9 products to the jar via packageBin/mappings, but that doesn't work with the OSGi plugin,
|
|
|
|
|
// so we add them to the fullClasspath instead.
|
|
|
|
|
// Compile / packageBin / mappings
|
|
|
|
|
// ++= (CompileJdk9 / products).value.flatMap(Path.allSubpaths),
|
2019-04-16 00:10:42 -07:00
|
|
|
Compile / fullClasspath ++= (CompileJdk9 / exportedProducts).value)
|
2018-07-02 16:38:07 +02:00
|
|
|
|
2019-12-16 11:45:13 +01:00
|
|
|
val testSettings = Seq((Test / test) := {
|
|
|
|
|
(Test / test).value
|
|
|
|
|
(TestJdk9 / test).value
|
|
|
|
|
})
|
|
|
|
|
|
2018-07-02 16:38:07 +02:00
|
|
|
override def trigger = noTrigger
|
|
|
|
|
override def projectConfigurations = Seq(CompileJdk9)
|
|
|
|
|
override lazy val projectSettings =
|
|
|
|
|
inConfig(CompileJdk9)(Defaults.compileSettings) ++
|
|
|
|
|
inConfig(CompileJdk9)(compileJdk9Settings) ++
|
2019-12-05 16:40:05 +01:00
|
|
|
compileSettings ++
|
|
|
|
|
inConfig(TestJdk9)(Defaults.testSettings) ++
|
2019-12-16 11:45:13 +01:00
|
|
|
inConfig(TestJdk9)(testJdk9Settings) ++
|
|
|
|
|
testSettings
|
2018-07-02 16:38:07 +02:00
|
|
|
}
|