Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
cchantep committed Sep 9, 2023
1 parent c5d291d commit d3b36bb
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 18 deletions.
13 changes: 13 additions & 0 deletions akka/src/test/scala-2.12+/StreamTestKit.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright (C) from 2022 The Play Framework Contributors <https://github.com/playframework>, 2011-2021 Lightbend Inc. <https://www.lightbend.com>
*/

package anorm

import akka.stream.Materializer
import akka.stream.testkit.scaladsl.{StreamTestKit=>AkkaTestKit}

private[anorm] object StreamTestKit {
def assertAllStagesStopped[T](f: => T)(implicit mat: Materializer): T =
AkkaTestKit.assertAllStagesStopped(f)
}
10 changes: 10 additions & 0 deletions akka/src/test/scala-2.12-/StreamTestKit.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright (C) from 2022 The Play Framework Contributors <https://github.com/playframework>, 2011-2021 Lightbend Inc. <https://www.lightbend.com>
*/

package anorm

/* No valid testkit for 2.11 */
private[anorm] object StreamTestKit {
def assertAllStagesStopped[T](f: => T): T = f
}
3 changes: 2 additions & 1 deletion akka/src/test/scala/anorm/AkkaStreamSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import akka.actor.ActorSystem

import akka.stream.Materializer
import akka.stream.scaladsl.{ Keep, Sink, Source }
import akka.stream.testkit.scaladsl.StreamTestKit.assertAllStagesStopped

import acolyte.jdbc.AcolyteDSL.withQueryResult
import acolyte.jdbc.Implicits._
Expand All @@ -33,6 +32,8 @@ final class AkkaStreamSpec(implicit ee: ExecutionEnv) extends org.specs2.mutable
implicit def materializer: Materializer =
akka.stream.ActorMaterializer.create(system)

import StreamTestKit.assertAllStagesStopped

"Akka Stream" should {
"expose the query result as source" in assertAllStagesStopped {
withQueryResult(stringList :+ "A" :+ "B" :+ "C") { implicit con =>
Expand Down
73 changes: 57 additions & 16 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,6 @@ lazy val akkaVer = Def.setting[String] {
}
}

lazy val pekkoVer = Def.setting[String]("1.0.1")

lazy val `anorm-akka` = (project in file("akka"))
.settings(
mimaPreviousArtifacts := {
Expand All @@ -278,7 +276,7 @@ lazy val `anorm-akka` = (project in file("akka"))
libraryDependencies ++= Seq(
acolyte,
"org.scala-lang.modules" %% "scala-xml" % xmlVer.value % Test,
"com.typesafe.akka" %% "akka-stream-testkit" % akkaVer.value % Test
("com.typesafe.akka" %% "akka-stream-testkit" % akkaVer.value % Test).exclude("org.scala-lang.modules", "*")
) ++ specs2Test,
scalacOptions ++= {
if (scalaBinaryVersion.value == "3") {
Expand All @@ -287,30 +285,75 @@ lazy val `anorm-akka` = (project in file("akka"))
Seq("-P:silencer:globalFilters=deprecated")
}
},
Test / unmanagedSourceDirectories ++= {
Test / unmanagedSourceDirectories += {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, n)) if n < 13 =>
Seq((Test / sourceDirectory).value / "scala-2.13-")
(Test / sourceDirectory).value / "scala-2.13-"

case _ =>
Seq((Test / sourceDirectory).value / "scala-2.13+")
(Test / sourceDirectory).value / "scala-2.13+"

}
},
Test / unmanagedSourceDirectories += {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) =>
(Test / sourceDirectory).value / "scala-2.12-"

case _ =>
(Test / sourceDirectory).value / "scala-2.12+"

}
}
)
.dependsOn(`anorm-core`)

lazy val pekkoVer = Def.setting[String]("1.0.1")

lazy val pekkoEnabled = Def.setting[Boolean] {
val v = scalaBinaryVersion.value

v != "2.11" && v != "2.12"
}

lazy val `anorm-pekko` = (project in file("pekko"))
.settings(
mimaPreviousArtifacts := Set.empty,
libraryDependencies ++= Seq("pekko-testkit", "pekko-stream").map { m =>
("org.apache.pekko" %% m % pekkoVer.value % Provided).exclude("org.scala-lang.modules", "*")
sourceDirectory := {
if (!pekkoEnabled.value) new java.io.File("/no/sources")
else sourceDirectory.value
},
publishArtifact := pekkoEnabled.value,
publish := Def.taskDyn {
val ver = scalaBinaryVersion.value
val go = publish.value

Def.task {
if (pekkoEnabled.value) {
go
}
}
}.value,
libraryDependencies ++= {
if (pekkoEnabled.value) {
Seq("pekko-testkit", "pekko-stream").map { m =>
("org.apache.pekko" %% m % pekkoVer.value % Provided).exclude("org.scala-lang.modules", "*")
}
} else {
Seq.empty
}
},
libraryDependencies ++= {
if (pekkoEnabled.value) {
Seq(
acolyte,
"org.scala-lang.modules" %% "scala-xml" % xmlVer.value % Test,
"org.apache.pekko" %% "pekko-stream-testkit" % pekkoVer.value % Test
) ++ specs2Test
} else {
Seq.empty
}
},
libraryDependencies ++= Seq(
acolyte,
"org.scala-lang.modules" %% "scala-xml" % xmlVer.value % Test,
"org.apache.pekko" %% "pekko-stream-testkit" % pekkoVer.value % Test
) ++ specs2Test,
scalacOptions ++= {
if (scalaBinaryVersion.value == "3") {
Seq("-Wconf:cat=deprecation&msg=.*(onDownstreamFinish|ActorMaterializer).*:s")
Expand All @@ -327,9 +370,7 @@ lazy val `anorm-pekko` = (project in file("pekko"))
Seq((Test / sourceDirectory).value / "scala-2.13+")

}
},
crossScalaVersions --= Seq("2.11.12", "2.12.18"),
mimaFailOnNoPrevious := false
}
)
.dependsOn(`anorm-core`)

Expand Down
2 changes: 1 addition & 1 deletion project/Common.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object Common extends AutoPlugin {
organization := "org.playframework.anorm",
sonatypeProfileName := "org.playframework",
scalaVersion := "2.12.18",
crossScalaVersions := Seq("2.11.12", scalaVersion.value, "2.13.11", "3.3.0"),
crossScalaVersions := Seq("2.11.12", scalaVersion.value, "2.13.11", "3.3.1"),
(Compile / unmanagedSourceDirectories) ++= {
val sv = scalaVersion.value

Expand Down

0 comments on commit d3b36bb

Please sign in to comment.