Skip to content

Commit

Permalink
fix the build for scala 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Andriy Onyshchuk committed Oct 18, 2023
1 parent 4826705 commit 9d9c671
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,6 @@ lazy val root = (project in file("."))
scalaStm,
slf4jApi,
slf4jSimple,
akkaHttp(scalaV.value).cross(CrossVersion.for3Use2_13),
akkaStream(scalaV.value).cross(CrossVersion.for3Use2_13)))
akkaHttp(scalaVersion.value).cross(CrossVersion.binary),
akkaStream(scalaVersion.value).cross(CrossVersion.binary)))

18 changes: 9 additions & 9 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sbt._
import sbt.*

object Dependencies {
lazy val Examples = config("example") extend Compile
Expand All @@ -14,10 +14,10 @@ object Dependencies {

object akkaHttp {

def apply(scalaVer: ScalaVer) = {
val v = scalaVer match {
case ScalaVer._211 => "10.1.9"
case _ => "10.2.6"
def apply(scalaVer: String): ModuleID = {
val v = ScalaVer.fromString(scalaVer) match {
case Some(ScalaVer._211) => "10.1.9"
case _ => "10.5.3"

}

Expand All @@ -26,10 +26,10 @@ object Dependencies {
}

object akkaStream {
def apply(scalaVer: ScalaVer) = {
val v = scalaVer match {
case ScalaVer._211 => "2.5.32"
case _ => "2.6.16"
def apply(scalaVer: String): ModuleID = {
val v = ScalaVer.fromString(scalaVer) match {
case Some(ScalaVer._211) => "2.5.32"
case _ => "2.8.5"
}

"com.typesafe.akka" %% "akka-stream" % v % Test
Expand Down
17 changes: 9 additions & 8 deletions project/ScalaVer.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sbt.Keys.{crossScalaVersions, scalaVersion}
import sbt.settingKey
import sbt.librarymanagement.CrossVersion
import sbt.{Def, settingKey}

sealed abstract class ScalaVer(val full: String)

Expand All @@ -19,17 +20,17 @@ object ScalaVer {

def fromEnv: Option[ScalaVer] = sys.env.get("SCALA_VER") flatMap fromString

def fromString(full: String): Option[ScalaVer] = full match {
case x if x startsWith "2.11" => Some(_211)
case x if x startsWith "2.12" => Some(_212)
case x if x startsWith "2.13" => Some(_213)
case x if x startsWith "3.0" => Some(_300)
case _ => None
def fromString(full: String): Option[ScalaVer] = CrossVersion.partialVersion(full) match {
case Some((2, 11)) => Some(_211)
case Some((2, 12)) => Some(_212)
case Some((2, 13)) => Some(_213)
case Some((3, _)) => Some(_300)
case _ => None
}

lazy val scalaV = settingKey[ScalaVer]("Current Scala Version")

def settings = Seq(
def settings: Seq[Def.Setting[? >: String & Seq[String] & ScalaVer <: Object]] = Seq(
scalaVersion := (ScalaVer.fromEnv getOrElse ScalaVer.default).full,
crossScalaVersions := ScalaVer.values.map(_.full),
scalaV := ScalaVer.fromString(scalaVersion.value) getOrElse ScalaVer.default)
Expand Down

0 comments on commit 9d9c671

Please sign in to comment.