Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get back scala 2.12 #280

Merged
merged 1 commit into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
}
}
Loading