From f6ab5ba571436f3b6ee928e65e52330359f9ad10 Mon Sep 17 00:00:00 2001 From: Enno <458526+ennru@users.noreply.github.com> Date: Thu, 20 Jun 2019 06:26:35 +0200 Subject: [PATCH] Versions for Scala 2.13.0 (#1755) * Versions for Scala 2.13.0 * SSE: Akka HTTP change, make actor system available to reach settings #1183 --- .travis.yml | 6 +-- build.sbt | 37 +++++++++++++------ project/Common.scala | 8 ++-- project/Dependencies.scala | 20 +++++----- .../alpakka/sse/scaladsl/EventSource.scala | 13 ++++++- 5 files changed, 54 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index 08bc5bdb44..907c4b18f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ jobs: name: "Build code style check (fixed with `sbt scalafmtSbt`)" - env: CMD="++2.11.12 Test/compile" name: "Compile all tests (with Scala 2.11)" - - env: CMD="++2.13.0-M5 Test/compile" + - env: CMD="++2.13.0 Test/compile" name: "Compile all tests (with Scala 2.13)" - env: CMD="unidoc" name: "Create all API docs" @@ -136,8 +136,8 @@ jobs: name: "Publish artifacts for Scala 2.11.12" - env: CMD="++2.12.7 publish" name: "Publish artifacts for Scala 2.12.7" - - env: CMD="++2.13.0-M5 publish" - name: "Publish artifacts for Scala 2.13.0-M5" + - env: CMD="++2.13.0 publish" + name: "Publish artifacts for Scala 2.13.0" - script: openssl aes-256-cbc -K $encrypted_bbf1dc4f2a07_key -iv $encrypted_bbf1dc4f2a07_iv -in .travis/travis_alpakka_rsa.enc -out .travis/id_rsa -d && eval "$(ssh-agent -s)" && chmod 600 .travis/id_rsa && ssh-add .travis/id_rsa && sbt -jvm-opts .jvmopts-travis docs/publishRsync name: "Publish API and reference documentation" diff --git a/build.sbt b/build.sbt index f460b1c21c..5b616e4aca 100644 --- a/build.sbt +++ b/build.sbt @@ -129,7 +129,7 @@ lazy val ftp = alpakkaProject( fork in Test := true, // To avoid potential blocking in machines with low entropy (default is `/dev/random`) javaOptions in Test += "-Djava.security.egd=file:/dev/./urandom", - crossScalaVersions -= Dependencies.Scala213 + crossScalaVersions -= Dependencies.Scala213 // https://github.com/akka/alpakka/issues/1532 ) lazy val geode = @@ -155,7 +155,8 @@ lazy val googleCloudPubSub = alpakkaProject( fork in Test := true, envVars in Test := Map("PUBSUB_EMULATOR_HOST" -> "localhost:8538"), // For mockito https://github.com/akka/alpakka/issues/390 - parallelExecution in Test := false + parallelExecution in Test := false, + crossScalaVersions -= Dependencies.Scala213 // requires upgrade of jwt-core to 3.0.1 ) lazy val googleCloudPubSubGrpc = alpakkaProject( @@ -169,25 +170,33 @@ lazy val googleCloudPubSubGrpc = alpakkaProject( // for the ExampleApp in the tests connectInput in run := true, Compile / compile / scalacOptions += "-P:silencer:pathFilters=src_managed", - crossScalaVersions --= Seq(Dependencies.Scala211, Dependencies.Scala213) + crossScalaVersions --= Seq(Dependencies.Scala211, Dependencies.Scala213) // https://github.com/akka/akka-grpc/pull/599 ).enablePlugins(AkkaGrpcPlugin, JavaAgent) lazy val googleFcm = alpakkaProject( "google-fcm", "google.firebase.fcm", Dependencies.GoogleFcm, - fork in Test := true + fork in Test := true, + crossScalaVersions -= Dependencies.Scala213 // requires upgrade of jwt-core to 3.0.1 ) lazy val hbase = alpakkaProject("hbase", "hbase", Dependencies.HBase, fork in Test := true) -lazy val hdfs = alpakkaProject("hdfs", "hdfs", Dependencies.Hdfs, parallelExecution in Test := false) +lazy val hdfs = alpakkaProject("hdfs", + "hdfs", + Dependencies.Hdfs, + parallelExecution in Test := false, + crossScalaVersions -= Dependencies.Scala213 // Requires upgrade of cats-core +) -lazy val ironmq = alpakkaProject("ironmq", - "ironmq", - Dependencies.IronMq, - fork in Test := true, - crossScalaVersions -= Dependencies.Scala213) +lazy val ironmq = alpakkaProject( + "ironmq", + "ironmq", + Dependencies.IronMq, + fork in Test := true, + crossScalaVersions -= Dependencies.Scala213 // https://github.com/hseeberger/akka-http-json/issues/253 +) lazy val jms = alpakkaProject("jms", "jms", Dependencies.Jms, parallelExecution in Test := false) @@ -202,7 +211,11 @@ lazy val kinesis = alpakkaProject("kinesis", lazy val kudu = alpakkaProject("kudu", "kudu", Dependencies.Kudu, fork in Test := false) lazy val mongodb = - alpakkaProject("mongodb", "mongodb", Dependencies.MongoDb, crossScalaVersions -= Dependencies.Scala213) + alpakkaProject("mongodb", + "mongodb", + Dependencies.MongoDb, + crossScalaVersions -= Dependencies.Scala213 // https://jira.mongodb.org/browse/SCALA-506 + ) lazy val mqtt = alpakkaProject("mqtt", "mqtt", Dependencies.Mqtt) @@ -233,7 +246,7 @@ lazy val springWeb = alpakkaProject("spring-web", "spring.web", Dependencies.Spr lazy val simpleCodecs = alpakkaProject("simple-codecs", "simplecodecs") -lazy val slick = alpakkaProject("slick", "slick", Dependencies.Slick, crossScalaVersions -= Dependencies.Scala213) +lazy val slick = alpakkaProject("slick", "slick", Dependencies.Slick) lazy val sns = alpakkaProject( "sns", diff --git a/project/Common.scala b/project/Common.scala index 68a3061e0e..486fb76159 100644 --- a/project/Common.scala +++ b/project/Common.scala @@ -40,15 +40,17 @@ object Common extends AutoPlugin { "-feature", "-unchecked", "-deprecation", - //"-Xfatal-warnings", "-Xlint", "-Ywarn-dead-code", - "-Xfuture", "-target:jvm-1.8" ), scalacOptions ++= (scalaVersion.value match { case Dependencies.Scala213 => Seq.empty[String] - case _ => Seq("-Yno-adapted-args") + case _ => + Seq( + "-Xfuture", + "-Yno-adapted-args" + ) }), Compile / doc / scalacOptions := scalacOptions.value ++ Seq( "-doc-title", diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 4329928f2f..4c5ef7d7a2 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -5,18 +5,18 @@ object Dependencies { val Scala211 = "2.11.12" val Scala212 = "2.12.7" - val Scala213 = "2.13.0-M5" + val Scala213 = "2.13.0" val ScalaVersions = Seq(Scala212, Scala211, Scala213) val AkkaVersion = sys.env.get("AKKA_SERIES") match { case Some("2.4") => sys.error("Akka 2.4 is not supported anymore") - case _ => "2.5.22" + case _ => "2.5.23" } val AwsSdkVersion = "1.11.476" val AwsSdk2Version = "2.5.65" - val AwsSpiAkkaHttpVersion = "0.0.6" - val AkkaHttpVersion = "10.1.7" + val AwsSpiAkkaHttpVersion = "0.0.7" + val AkkaHttpVersion = "10.1.8" val mockitoVersion = "2.28.2" val CouchbaseVersion = "2.7.2" @@ -26,7 +26,7 @@ object Dependencies { // This is only compile time dependency, therefore it does not affect the generated bytecode // https://github.com/ghik/silencer val Silencer = { - val Version = "1.3.1" + val Version = "1.4.1" Seq( compilerPlugin("com.github.ghik" %% "silencer-plugin" % Version), "com.github.ghik" %% "silencer-lib" % Version % Provided @@ -40,7 +40,7 @@ object Dependencies { "com.typesafe.akka" %% "akka-stream-testkit" % AkkaVersion % Test, "com.typesafe.akka" %% "akka-slf4j" % AkkaVersion % Test, "ch.qos.logback" % "logback-classic" % "1.2.3" % Test, // Eclipse Public License 1.0 - "org.scalatest" %% "scalatest" % "3.0.7" % Test, // ApacheV2 + "org.scalatest" %% "scalatest" % "3.0.8" % Test, // ApacheV2 "com.novocode" % "junit-interface" % "0.11" % Test, // BSD-style "junit" % "junit" % "4.12" % Test // Eclipse Public License 1.0 ) @@ -77,7 +77,7 @@ object Dependencies { libraryDependencies ++= Seq( "com.couchbase.client" % "java-client" % CouchbaseVersion, // ApacheV2 "io.reactivex" % "rxjava-reactive-streams" % "1.2.1", //ApacheV2 - "com.typesafe.play" %% "play-json" % "2.7.1" % Test, // MIT like: http://www.slf4j.org/license.html + "com.typesafe.play" %% "play-json" % "2.7.4" % Test, // MIT like: http://www.slf4j.org/license.html "com.typesafe.akka" %% "akka-http" % AkkaHttpVersion % Test // Apache V2 ) ) @@ -144,7 +144,7 @@ object Dependencies { "org.apache.parquet" % "parquet-avro" % "1.10.0", //Apache2 "org.apache.hadoop" % "hadoop-client" % "3.1.0" % Test exclude ("log4j", "log4j"), //Apache2 "org.apache.hadoop" % "hadoop-common" % "2.2.0" % Test exclude ("log4j", "log4j"), //Apache2 - "org.specs2" %% "specs2-core" % "4.4.1" % Test, //MIT like: https://github.com/etorreborre/specs2/blob/master/LICENSE.txt + "org.specs2" %% "specs2-core" % "4.5.1" % Test, //MIT like: https://github.com/etorreborre/specs2/blob/master/LICENSE.txt "org.slf4j" % "log4j-over-slf4j" % "1.7.25" % Test // MIT like: http://www.slf4j.org/license.html ) ) @@ -243,7 +243,7 @@ object Dependencies { "com.ibm.mq" % "com.ibm.mq.allclient" % "9.1.1.0" % Test, // IBM International Program License Agreement https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqdev/maven/licenses/L-APIG-AZYF2E/LI_en.html "org.apache.activemq" % "activemq-broker" % "5.15.4" % Test, // ApacheV2 "org.apache.activemq" % "activemq-client" % "5.15.4" % Test, // ApacheV2 - "io.github.sullis" %% "jms-testkit" % "0.2.1" % Test, // ApacheV2 + "io.github.sullis" %% "jms-testkit" % "0.2.6" % Test, // ApacheV2 "org.mockito" % "mockito-core" % mockitoVersion % Test // MIT ), // Having JBoss as a first resolver is a workaround for https://github.com/coursier/coursier/issues/200 @@ -332,7 +332,7 @@ object Dependencies { ) } - val SlickVersion = "3.3.0" + val SlickVersion = "3.3.2" val Slick = Seq( libraryDependencies ++= Seq( "com.typesafe.slick" %% "slick" % SlickVersion, // BSD 2-clause "Simplified" License diff --git a/sse/src/main/scala/akka/stream/alpakka/sse/scaladsl/EventSource.scala b/sse/src/main/scala/akka/stream/alpakka/sse/scaladsl/EventSource.scala index 66e0753869..1b58c89c1c 100644 --- a/sse/src/main/scala/akka/stream/alpakka/sse/scaladsl/EventSource.scala +++ b/sse/src/main/scala/akka/stream/alpakka/sse/scaladsl/EventSource.scala @@ -6,17 +6,19 @@ package akka.stream.alpakka.sse package scaladsl import akka.NotUsed +import akka.actor.ActorSystem import akka.http.scaladsl.client.RequestBuilding.Get import akka.http.scaladsl.model.headers.Accept import akka.http.scaladsl.model.{HttpRequest, HttpResponse, Uri} import akka.http.scaladsl.unmarshalling.Unmarshal import akka.stream.scaladsl.{Broadcast, Flow, GraphDSL, Merge, Source} -import akka.stream.{Materializer, SourceShape} +import akka.stream.{ActorMaterializer, Materializer, SourceShape} import akka.http.scaladsl.model.sse.ServerSentEvent import akka.http.scaladsl.model.sse.ServerSentEvent.heartbeat import akka.http.scaladsl.model.MediaTypes.`text/event-stream` import akka.http.scaladsl.model.headers.`Last-Event-ID` import akka.http.scaladsl.unmarshalling.sse.EventStreamUnmarshalling + import scala.concurrent.Future import scala.concurrent.duration.{Duration, FiniteDuration} @@ -85,8 +87,9 @@ object EventSource { retryDelay: FiniteDuration = Duration.Zero)( implicit mat: Materializer ): EventSource = { - import EventStreamUnmarshalling._ + import EventStreamUnmarshalling.fromEventsStream import mat.executionContext + implicit val system: ActorSystem = actorMaterializer(mat).system val continuousEvents = { def getEventSource(lastEventId: Option[String]) = { @@ -125,4 +128,10 @@ object EventSource { SourceShape(events.out) }) } + + private def actorMaterializer(mat: Materializer): ActorMaterializer = mat match { + case am: ActorMaterializer => am + case _ => throw new Error("ActorMaterializer required") + } + }