Fix publishing akka-stream_2.12 with jdk8 and jdk9 classes (#25341)
* Fix publishing akka-stream_2.12 with jdk8 and jdk9 classes * Only build jdk9 classes on jdk9+ * Avoid -release on jdk8
This commit is contained in:
parent
231672fc1c
commit
97490eb30c
3 changed files with 20 additions and 8 deletions
|
|
@ -97,7 +97,7 @@ object AkkaBuild {
|
|||
// methods not found in jdk8. To test whether this has the desired effect, compile akka-remote and check the
|
||||
// invocation of 'ByteBuffer.clear()' in EnvelopeBuffer.class with 'javap -c': it should refer to
|
||||
// "java/nio/ByteBuffer.clear:()Ljava/nio/Buffer" and not "java/nio/ByteBuffer.clear:()Ljava/nio/ByteBuffer":
|
||||
scalacOptions in Compile ++= (if (scalaBinaryVersion.value == "2.11") Seq("-target:jvm-1.8", "-javabootclasspath", CrossJava.Keys.fullJavaHomes.value("8") + "/jre/lib/rt.jar") else Seq("-release", "8")),
|
||||
scalacOptions in Compile ++= (if (scalaBinaryVersion.value == "2.11" || System.getProperty("java.version").startsWith("1.")) Seq("-target:jvm-1.8", "-javabootclasspath", CrossJava.Keys.fullJavaHomes.value("8") + "/jre/lib/rt.jar") else Seq("-release", "8")),
|
||||
scalacOptions in Compile ++= (if (allWarnings) Seq("-deprecation") else Nil),
|
||||
scalacOptions in Test := (scalacOptions in Test).value.filterNot(opt ⇒
|
||||
opt == "-Xlog-reflective-calls" || opt.contains("genjavadoc")),
|
||||
|
|
|
|||
|
|
@ -11,19 +11,31 @@ object Jdk9 extends AutoPlugin {
|
|||
|
||||
lazy val CompileJdk9 = config("CompileJdk9").extend(Compile)
|
||||
|
||||
def notOnScala211[T](scalaBinaryVersion: String, values: Seq[T]): Seq[T] = scalaBinaryVersion match {
|
||||
case "2.11" => Seq()
|
||||
case _ => values
|
||||
}
|
||||
|
||||
def notOnJdk8[T](values: Seq[T]): Seq[T] =
|
||||
if (System.getProperty("java.version").startsWith("1.")) Seq()
|
||||
else values
|
||||
|
||||
val compileJdk9Settings = Seq(
|
||||
// following the scala-2.12, scala-sbt-1.0, ... convention
|
||||
unmanagedSourceDirectories := Seq(
|
||||
unmanagedSourceDirectories := notOnJdk8(notOnScala211(scalaBinaryVersion.value, Seq(
|
||||
(Compile / sourceDirectory).value / "scala-jdk-9",
|
||||
(Compile / sourceDirectory).value / "java-jdk-9"
|
||||
),
|
||||
scalacOptions := AkkaBuild.DefaultScalacOptions ++ Seq("-release", "9"),
|
||||
javacOptions := AkkaBuild.DefaultJavacOptions ++ Seq("--release", "9")
|
||||
))),
|
||||
scalacOptions := AkkaBuild.DefaultScalacOptions ++ notOnJdk8(notOnScala211(scalaBinaryVersion.value, Seq("-release", "9"))),
|
||||
javacOptions := AkkaBuild.DefaultJavacOptions ++ notOnJdk8(notOnScala211(scalaBinaryVersion.value, Seq("--release", "9")))
|
||||
)
|
||||
|
||||
val compileSettings = Seq(
|
||||
Compile / packageBin / mappings ++=
|
||||
(CompileJdk9 / products).value.flatMap(Path.allSubpaths)
|
||||
// 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),
|
||||
Compile / fullClasspath ++= (CompileJdk9 / exportedProducts).value
|
||||
)
|
||||
|
||||
override def trigger = noTrigger
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ object OSGi {
|
|||
// in the .../bundles directory which makes testing locally published artifacts
|
||||
// a pain. Create bundles but publish them to the normal .../jars directory.
|
||||
def osgiSettings = defaultOsgiSettings ++ Seq(
|
||||
packagedArtifact in (Compile, packageBin) := ((artifact in (Compile, packageBin)).value, OsgiKeys.bundle.value),
|
||||
Compile / packageBin := OsgiKeys.bundle.value,
|
||||
// This will fail the build instead of accidentally removing classes from the resulting artifact.
|
||||
// Each package contained in a project MUST be known to be private or exported, if it's undecided we MUST resolve this
|
||||
OsgiKeys.failOnUndecidedPackage := true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue