From 5f07225b7a173e9cb87b5169e9aada8b0e76faf8 Mon Sep 17 00:00:00 2001 From: Ben Plommer Date: Mon, 17 May 2021 10:17:02 +0100 Subject: [PATCH 1/2] Update to Scala 3 final --- build.sbt | 20 +++++++++---------- .../core/src/test/scala/vulcan/BaseSpec.scala | 14 ++++++++++++- project/plugins.sbt | 1 - 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/build.sbt b/build.sbt index cd2528f0..a3e489cc 100644 --- a/build.sbt +++ b/build.sbt @@ -1,12 +1,12 @@ val avroVersion = "1.10.2" -val catsVersion = "2.6.0" +val catsVersion = "2.6.1" val enumeratumVersion = "1.6.1" val magnoliaVersion = "0.17.0" -val refinedVersion = "0.9.24" +val refinedVersion = "0.9.25" val shapelessVersion = "2.3.7" @@ -14,7 +14,7 @@ val scala212 = "2.12.13" val scala213 = "2.13.5" -val scala3 = "3.0.0-RC3" +val scala3 = "3.0.0" lazy val vulcan = project .in(file(".")) @@ -37,7 +37,7 @@ lazy val core = project "org.apache.avro" % "avro" % avroVersion, "org.typelevel" %% "cats-free" % catsVersion ) ++ { - if (isDotty.value) Nil + if (scalaVersion.value.startsWith("3")) Nil else Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided) } ), @@ -125,7 +125,7 @@ lazy val docs = project lazy val dependencySettings = Seq( libraryDependencies ++= { - if (isDotty.value) Nil + if (scalaVersion.value.startsWith("3")) Nil else Seq( "org.scala-lang.modules" %% "scala-collection-compat" % "2.4.4" % Test, @@ -148,7 +148,7 @@ lazy val dependencySettings = Seq( lazy val scalatestSettings = Seq( libraryDependencies ++= Seq( - "org.typelevel" %% "discipline-scalatest" % "2.1.4", + "org.typelevel" %% "discipline-scalatest" % "2.1.5", "org.typelevel" %% "cats-testkit" % catsVersion, "org.slf4j" % "slf4j-nop" % "1.7.30" ).map(_ % Test) @@ -267,7 +267,7 @@ lazy val publishSettings = lazy val mimaSettings = Seq( mimaPreviousArtifacts := { - if (publishArtifact.value && !isDotty.value) { + if (publishArtifact.value && !scalaVersion.value.startsWith("3")) { // enable mima for Scala 3 after first release Set(organization.value %% moduleName.value % (ThisBuild / previousStableVersion).value.get) } else Set() }, @@ -334,11 +334,9 @@ lazy val scalaSettings = Seq( } else Seq() val scala3ScalacOptions = - if (isDotty.value) { + if (scalaVersion.value.startsWith("3")) { Seq( - "-Ykind-projector", - "-source:3.0-migration", - "-Xignore-scala2-macros" + "-Ykind-projector" ) } else Seq() diff --git a/modules/core/src/test/scala/vulcan/BaseSpec.scala b/modules/core/src/test/scala/vulcan/BaseSpec.scala index a5b3daa2..0ebfc2ff 100644 --- a/modules/core/src/test/scala/vulcan/BaseSpec.scala +++ b/modules/core/src/test/scala/vulcan/BaseSpec.scala @@ -2,5 +2,17 @@ package vulcan import org.scalatest.funspec.AnyFunSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks +import org.scalactic.Equality +import cats.kernel.Eq +import scala.reflect.ClassTag -class BaseSpec extends AnyFunSpec with ScalaCheckPropertyChecks with EitherValues +class BaseSpec extends AnyFunSpec with ScalaCheckPropertyChecks with EitherValues { + + // In Scala 3, `===` uses Scalactic rather than Cats syntax + implicit def catsEquality[A: Eq: ClassTag]: Equality[A] = new Equality[A] { + def areEqual(a: A, b: Any): Boolean = b match { + case b: A => Eq[A].eqv(a, b) + case _ => false + } + } +} diff --git a/project/plugins.sbt b/project/plugins.sbt index 1de2cb87..c05b17ba 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -5,4 +5,3 @@ addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.9.1") addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0") addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.21") addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2") -addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.5.5") From 32070fdd9c6cbe52ce84372b8f47a5b8a4151812 Mon Sep 17 00:00:00 2001 From: Ben Plommer Date: Mon, 17 May 2021 10:20:51 +0100 Subject: [PATCH 2/2] Format build.sbt --- build.sbt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index a3e489cc..e46676b3 100644 --- a/build.sbt +++ b/build.sbt @@ -267,7 +267,8 @@ lazy val publishSettings = lazy val mimaSettings = Seq( mimaPreviousArtifacts := { - if (publishArtifact.value && !scalaVersion.value.startsWith("3")) { // enable mima for Scala 3 after first release + if (publishArtifact.value && !scalaVersion.value + .startsWith("3")) { // enable mima for Scala 3 after first release Set(organization.value %% moduleName.value % (ThisBuild / previousStableVersion).value.get) } else Set() },