diff --git a/.github/workflows/check-build-test.yml b/.github/workflows/check-build-test.yml index eec0633491..8504ba707c 100644 --- a/.github/workflows/check-build-test.yml +++ b/.github/workflows/check-build-test.yml @@ -41,8 +41,8 @@ jobs: - name: Cache Coursier cache uses: coursier/cache-action@v6.4.0 - - name: "Code style, compile tests, MiMa. Run locally with: sbt +~2.13 \"verifyCodeStyle; Test/compile; mimaReportBinaryIssues\"" - run: sbt +~2.13 "verifyCodeStyle; Test/compile; mimaReportBinaryIssues" + - name: "Code style, compile tests, MiMa. Run locally with: sbt \"verifyCodeStyle; +Test/compile; mimaReportBinaryIssues\"" + run: sbt "verifyCodeStyle; +Test/compile; mimaReportBinaryIssues" documentation: name: ScalaDoc, Documentation with Paradox diff --git a/build.sbt b/build.sbt index 01881c986a..098356c11c 100644 --- a/build.sbt +++ b/build.sbt @@ -131,11 +131,12 @@ lazy val azureStorageQueue = alpakkaProject( lazy val cassandra = alpakkaProject("cassandra", "cassandra", Dependencies.Cassandra) + .settings(Scala3.settings) lazy val couchbase = alpakkaProject("couchbase", "couchbase", Dependencies.Couchbase) -lazy val csv = alpakkaProject("csv", "csv") +lazy val csv = alpakkaProject("csv", "csv").settings(Scala3.settings) lazy val csvBench = internalProject("csv-bench") .dependsOn(csv) @@ -444,6 +445,7 @@ lazy val docs = project ) lazy val testkit = internalProject("testkit", Dependencies.testkit) + .settings(Scala3.settings) // needed for modules that depend on testKit, e.g. csv lazy val `doc-examples` = project .enablePlugins(AutomateHeaderPlugin) diff --git a/cassandra/src/main/scala/akka/stream/alpakka/cassandra/javadsl/CassandraSession.scala b/cassandra/src/main/scala/akka/stream/alpakka/cassandra/javadsl/CassandraSession.scala index 2f5a125291..e385bd41dc 100644 --- a/cassandra/src/main/scala/akka/stream/alpakka/cassandra/javadsl/CassandraSession.scala +++ b/cassandra/src/main/scala/akka/stream/alpakka/cassandra/javadsl/CassandraSession.scala @@ -74,7 +74,7 @@ final class CassandraSession(@InternalApi private[akka] val delegate: scaladsl.C onClose: java.lang.Runnable) = this(system.classicSystem, sessionProvider, executionContext, log, metricsCategory, init, onClose) - implicit private val ec = delegate.ec + implicit private val ec: ExecutionContext = delegate.ec /** * Closes the underlying Cassandra session. diff --git a/cassandra/src/test/scala/akka/stream/alpakka/cassandra/scaladsl/CassandraSessionPerformanceSpec.scala b/cassandra/src/test/scala/akka/stream/alpakka/cassandra/scaladsl/CassandraSessionPerformanceSpec.scala index 15374219b4..7b9e4d3d0b 100644 --- a/cassandra/src/test/scala/akka/stream/alpakka/cassandra/scaladsl/CassandraSessionPerformanceSpec.scala +++ b/cassandra/src/test/scala/akka/stream/alpakka/cassandra/scaladsl/CassandraSessionPerformanceSpec.scala @@ -15,7 +15,7 @@ import scala.concurrent.duration._ final class CassandraSessionPerformanceSpec extends CassandraSpecBase(ActorSystem("CassandraSessionPerformanceSpec")) { - val log = Logging(system, this.getClass) + val log = Logging(system, this.getClass.asInstanceOf[Class[Any]]) val data = 1 to 5 * 1000 * 1000 diff --git a/cassandra/src/test/scala/docs/javadsl/CassandraSessionSpec.scala b/cassandra/src/test/scala/docs/javadsl/CassandraSessionSpec.scala index 2d2f38da39..6d6be1b23c 100644 --- a/cassandra/src/test/scala/docs/javadsl/CassandraSessionSpec.scala +++ b/cassandra/src/test/scala/docs/javadsl/CassandraSessionSpec.scala @@ -28,7 +28,7 @@ import scala.concurrent.duration._ final class CassandraSessionSpec extends CassandraSpecBase(ActorSystem("CassandraSessionSpec")) { - val log = Logging(system, this.getClass) + val log = Logging(system, this.getClass.asInstanceOf[Class[Any]]) val javadslSessionRegistry = javadsl.CassandraSessionRegistry.get(system) val data = 1 until 103 diff --git a/csv/src/test/scala/docs/scaladsl/CsvParsingSpec.scala b/csv/src/test/scala/docs/scaladsl/CsvParsingSpec.scala index d8301b411e..7c730e23a9 100644 --- a/csv/src/test/scala/docs/scaladsl/CsvParsingSpec.scala +++ b/csv/src/test/scala/docs/scaladsl/CsvParsingSpec.scala @@ -5,10 +5,10 @@ package docs.scaladsl import java.nio.file.Paths - import akka.NotUsed import akka.stream.alpakka.csv.scaladsl.{CsvParsing, CsvToMap} import akka.stream.scaladsl.{FileIO, Flow, Keep, Sink, Source} +import akka.stream.testkit.{TestPublisher, TestSubscriber} import akka.stream.testkit.scaladsl.StreamTestKit.assertAllStagesStopped import akka.stream.testkit.scaladsl.{TestSink, TestSource} import akka.util.ByteString @@ -120,7 +120,7 @@ class CsvParsingSpec extends CsvSpec { } "emit completion even without new line at end" in assertAllStagesStopped { - val (source, sink) = TestSource[ByteString]() + val (source: TestPublisher.Probe[ByteString], sink: TestSubscriber.Probe[List[String]]) = TestSource[ByteString]() .via(CsvParsing.lineScanner()) .map(_.map(_.utf8String)) .toMat(TestSink[List[String]]())(Keep.both) diff --git a/csv/src/test/scala/docs/scaladsl/CsvSpec.scala b/csv/src/test/scala/docs/scaladsl/CsvSpec.scala index d5eec85cd7..7ffefc413a 100644 --- a/csv/src/test/scala/docs/scaladsl/CsvSpec.scala +++ b/csv/src/test/scala/docs/scaladsl/CsvSpec.scala @@ -4,7 +4,8 @@ package docs.scaladsl -import akka.actor.ActorSystem +import akka.actor.{ActorSystem, ClassicActorSystemProvider} +import akka.stream.Materializer import akka.stream.alpakka.testkit.scaladsl.LogCapturing import akka.testkit.TestKit import org.scalatest.concurrent.ScalaFutures @@ -20,7 +21,9 @@ abstract class CsvSpec with ScalaFutures with LogCapturing { - implicit val system = ActorSystem(this.getClass.getSimpleName) + implicit val system: ActorSystem = ActorSystem(this.getClass.getSimpleName) + implicit val classic: ClassicActorSystemProvider = system + implicit val mat: Materializer = Materializer(system) override protected def afterAll(): Unit = TestKit.shutdownActorSystem(system) diff --git a/mongodb/src/test/scala/docs/scaladsl/MongoSinkSpec.scala b/mongodb/src/test/scala/docs/scaladsl/MongoSinkSpec.scala index ba7073c9dc..5f77699c18 100644 --- a/mongodb/src/test/scala/docs/scaladsl/MongoSinkSpec.scala +++ b/mongodb/src/test/scala/docs/scaladsl/MongoSinkSpec.scala @@ -54,7 +54,7 @@ class MongoSinkSpec private val domainObjectsDocumentColl = db.getCollection("domainObjectsSink") implicit val defaultPatience = - PatienceConfig(timeout = 5.seconds, interval = 50.millis) + PatienceConfig(timeout = 10.seconds, interval = 100.millis) override def afterEach(): Unit = { Source.fromPublisher(numbersDocumentColl.deleteMany(new Document())).runWith(Sink.head).futureValue diff --git a/project/Common.scala b/project/Common.scala index c383f613e3..a112eb743f 100644 --- a/project/Common.scala +++ b/project/Common.scala @@ -41,7 +41,7 @@ object Common extends AutoPlugin { override lazy val projectSettings = Dependencies.Common ++ Seq( projectInfoVersion := (if (isSnapshot.value) "snapshot" else version.value), crossVersion := CrossVersion.binary, - crossScalaVersions := Dependencies.ScalaVersions, + crossScalaVersions := Dependencies.Scala2Versions, scalaVersion := Dependencies.Scala213, scalacOptions ++= Seq( "-encoding", @@ -55,7 +55,8 @@ object Common extends AutoPlugin { "8" ), scalacOptions ++= (scalaVersion.value match { - case Dependencies.Scala213 if insideCI.value && fatalWarnings.value && !Dependencies.CronBuild => + case Dependencies.Scala213 + if insideCI.value && fatalWarnings.value && !Dependencies.CronBuild && scalaVersion.value != Dependencies.Scala3 => Seq("-Werror") case _ => Seq.empty[String] }), @@ -65,14 +66,20 @@ object Common extends AutoPlugin { "-doc-version", version.value, "-sourcepath", - (ThisBuild / baseDirectory).value.toString, - "-skip-packages", - "akka.pattern:" + // for some reason Scaladoc creates this - "org.mongodb.scala:" + // this one is a mystery as well + (ThisBuild / baseDirectory).value.toString + ) ++ { // excluding generated grpc classes, except the model ones (com.google.pubsub) - "com.google.api:com.google.cloud:com.google.iam:com.google.logging:" + - "com.google.longrunning:com.google.protobuf:com.google.rpc:com.google.type" - ), + val skip = "akka.pattern:" + // for some reason Scaladoc creates this + "org.mongodb.scala:" + // this one is a mystery as well + // excluding generated grpc classes, except the model ones (com.google.pubsub) + "com.google.api:com.google.cloud:com.google.iam:com.google.logging:" + + "com.google.longrunning:com.google.protobuf:com.google.rpc:com.google.type" + if (scalaBinaryVersion.value.startsWith("3")) { + Seq(s"-skip-packages:$skip") // different usage in scala3 + } else { + Seq("-skip-packages", skip) + } + }, Compile / doc / scalacOptions ++= Seq( "-doc-source-url", { diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 639dee1ffd..36064aa9cb 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -7,7 +7,9 @@ object Dependencies { val Scala213 = "2.13.10" // update even in link-validator.conf val Scala212 = "2.12.17" - val ScalaVersions = Seq(Scala213, Scala212) + val Scala3 = "3.1.3" + val Scala2Versions = Seq(Scala213, Scala212) + val ScalaVersions = Dependencies.Scala2Versions :+ Dependencies.Scala3 val AkkaVersion = "2.7.0" val AkkaBinaryVersion = "2.7" diff --git a/project/Scala3.scala b/project/Scala3.scala new file mode 100644 index 0000000000..339150b63b --- /dev/null +++ b/project/Scala3.scala @@ -0,0 +1,7 @@ +import sbt.Keys.crossScalaVersions + +object Scala3 { + + val settings = Seq(crossScalaVersions := Dependencies.ScalaVersions) + +}