2023-01-08 17:13:31 +08:00
|
|
|
/*
|
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
|
* license agreements; and to You under the Apache License, version 2.0:
|
|
|
|
|
*
|
|
|
|
|
* https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* This file is part of the Apache Pekko project, derived from Akka.
|
|
|
|
|
*/
|
|
|
|
|
|
2018-07-02 16:38:07 +02:00
|
|
|
/*
|
2022-02-04 12:36:44 +01:00
|
|
|
* Copyright (C) 2017-2022 Lightbend Inc. <https://www.lightbend.com>
|
2018-07-02 16:38:07 +02:00
|
|
|
*/
|
|
|
|
|
|
2022-11-12 10:21:24 +01:00
|
|
|
package org.apache.pekko
|
2018-07-02 16:38:07 +02:00
|
|
|
|
|
|
|
|
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(
|
2022-11-03 09:46:22 +01:00
|
|
|
Seq(
|
|
|
|
|
(Compile / sourceDirectory).value / SCALA_SOURCE_DIRECTORY,
|
|
|
|
|
(Compile / sourceDirectory).value / JAVA_SOURCE_DIRECTORY)),
|
2022-12-02 14:49:16 +01:00
|
|
|
scalacOptions := PekkoBuild.DefaultScalacOptions.value ++ notOnJdk8(Seq("-release", "11")),
|
|
|
|
|
javacOptions := PekkoBuild.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(
|
2022-11-03 09:46:22 +01:00
|
|
|
Seq(
|
|
|
|
|
(Test / sourceDirectory).value / SCALA_TEST_SOURCE_DIRECTORY,
|
|
|
|
|
(Test / sourceDirectory).value / JAVA_TEST_SOURCE_DIRECTORY)),
|
2022-12-02 14:49:16 +01:00
|
|
|
scalacOptions := PekkoBuild.DefaultScalacOptions.value ++ notOnJdk8(Seq("-release", "11")),
|
|
|
|
|
javacOptions := PekkoBuild.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
|
|
|
}
|