diff --git a/project/AkkaBuild.scala b/project/AkkaBuild.scala index 83a63abdf9..847d967b99 100644 --- a/project/AkkaBuild.scala +++ b/project/AkkaBuild.scala @@ -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")), diff --git a/project/Jdk9.scala b/project/Jdk9.scala index e8e6eda7de..e8857bd3b9 100644 --- a/project/Jdk9.scala +++ b/project/Jdk9.scala @@ -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 diff --git a/project/OSGi.scala b/project/OSGi.scala index 457956cb92..cce473243d 100644 --- a/project/OSGi.scala +++ b/project/OSGi.scala @@ -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,