Skip to content

Commit

Permalink
get back scala 2.12 (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
dos65 committed Mar 30, 2024
1 parent 5305259 commit 0fc4b10
Show file tree
Hide file tree
Showing 37 changed files with 32 additions and 13 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/scala.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
# FIXME Use stable scala version
scala: [2.13.12, 3.3.0]
scala: [2.12.19, 2.13.12, 3.3.0]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/test-output
/project/target
/project/project
metals.sbt
.cache
.history
.lib
Expand All @@ -25,5 +26,6 @@ gpg.sbt
modules/**/target
*/jmh-result.json

.vscode
.metals
.bloop
20 changes: 9 additions & 11 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
lazy val scala212 = "2.12.19"
lazy val scala213 = "2.13.12"
/* FIXME
Return to use a stable version when 'scala.quoted.Quotes.reflectModuleSymbol.newClass'
Expand Down Expand Up @@ -66,7 +67,7 @@ def crossScalaSettings = {
}

Seq(
crossScalaVersions := Seq(scala213, scala3),
crossScalaVersions := Seq(scala212, scala213, scala3),
Compile / unmanagedSourceDirectories ++= addDirsByScalaVersion("src/main").value,
Test / unmanagedSourceDirectories ++= addDirsByScalaVersion("src/test").value
)
Expand All @@ -89,12 +90,10 @@ lazy val tethys = project.in(file("."))

lazy val modules = file("modules")

def addScalaCompiler(scalaVersion: String): Seq[ModuleID] =
def addScalaReflect(scalaVersion: String): Seq[ModuleID] =
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, y)) if y >= 13 =>
Seq("org.scala-lang" % "scala-compiler" % scalaVersion % Provided)
case Some((3, _)) =>
Seq("org.scala-lang" %% "scala3-compiler" % scalaVersion % Provided)
case Some((2, y)) =>
Seq("org.scala-lang" % "scala-reflect" % scalaVersion)
case _ => Seq.empty
}

Expand All @@ -104,7 +103,7 @@ lazy val core = project.in(modules / "core")
.settings(testSettings)
.settings(
name := "tethys-core",
libraryDependencies ++= addScalaCompiler(scalaVersion.value)
libraryDependencies ++= addScalaReflect(scalaVersion.value)
)

lazy val `macro-derivation` = project.in(modules / "macro-derivation")
Expand All @@ -113,7 +112,7 @@ lazy val `macro-derivation` = project.in(modules / "macro-derivation")
.settings(testSettings)
.settings(
name := "tethys-derivation",
libraryDependencies ++= addScalaCompiler(scalaVersion.value)
libraryDependencies ++= addScalaReflect(scalaVersion.value)
)
.dependsOn(core)

Expand Down Expand Up @@ -190,13 +189,12 @@ lazy val enumeratum = project.in(modules / "enumeratum")
.settings(crossScalaSettings)
.settings(commonSettings)
.settings(testSettings)
.settings(crossScalaVersions := Seq(scala213))
.settings(
name := "tethys-enumeratum",
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, y)) if y >= 13 =>
Seq("com.beachape" %% "enumeratum" % "1.7.2")
case Some((2, y)) =>
Seq("com.beachape" %% "enumeratum" % "1.7.3")
case _ => Seq.empty
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package tethys.compat

import scala.collection.generic.CanBuildFrom
import scala.collection.mutable
import scala.language.higherKinds

trait CollectionBuilder[A, C] {
def newBuilder: mutable.Builder[A, C]
}

object CollectionBuilder {
implicit def seqCBFBuilder[A, C[_]](implicit cbf: CanBuildFrom[Nothing, A, C[A]]): CollectionBuilder[A, C[A]] = new CollectionBuilder[A, C[A]] {
override def newBuilder: mutable.Builder[A, C[A]] = cbf()
}

implicit def mapCBFBuilder[K, V, M[_, _]](implicit cbf: CanBuildFrom[Nothing, (K, V), M[K, V]]): CollectionBuilder[(K, V), M[K, V]] =
new CollectionBuilder[(K, V), M[K, V]] {
override def newBuilder: mutable.Builder[(K, V), M[K, V]] = cbf()
}
}

0 comments on commit 0fc4b10

Please sign in to comment.