diff --git a/build.sbt b/build.sbt index ba3cafec0f..4d8e39a6ed 100644 --- a/build.sbt +++ b/build.sbt @@ -1007,8 +1007,8 @@ lazy val `fundamentals-json-circe` = project.in(file("fundamentals/fundamentals- ), libraryDependencies ++= { if (scalaVersion.value.startsWith("2.")) Seq( compilerPlugin("org.typelevel" % "kind-projector" % V.kind_projector cross CrossVersion.full), - "io.circe" %% "circe-derivation" % V.circe_derivation, - "org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided + "org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided, + "io.circe" %% "circe-derivation" % V.circe_derivation % Test ) else Seq.empty }, libraryDependencies ++= { val version = scalaVersion.value @@ -1164,7 +1164,9 @@ lazy val `fundamentals-json-circe` = project.in(file("fundamentals/fundamentals- ) case (_, _) => Seq.empty } }, - Test / packageDoc / publishArtifact := false + Test / packageDoc / publishArtifact := false, + Compile / libraryDependencySchemes += "io.circe" %% "circe-core" % VersionScheme.Always, + Compile / libraryDependencySchemes += "io.circe" %% "circe-core_sjs1" % VersionScheme.Always ) .disablePlugins(AssemblyPlugin) @@ -3524,13 +3526,13 @@ lazy val `logstage-core` = project.in(file("logstage/logstage-core")) lazy val `logstage-rendering-circe` = project.in(file("logstage/logstage-rendering-circe")) .dependsOn( - `fundamentals-json-circe` % "test->compile;compile->compile", `logstage-core` % "test->test;compile->compile" ) .settings( libraryDependencies ++= Seq( "org.scala-lang.modules" %% "scala-collection-compat" % V.collection_compat, "org.scalatest" %% "scalatest" % V.scalatest % Test, + "io.circe" %% "circe-core" % V.circe, "org.typelevel" %% "jawn-parser" % V.jawn % Test, "io.circe" %% "circe-parser" % V.circe % Test, "io.circe" %% "circe-literal" % V.circe % Test, @@ -4057,7 +4059,8 @@ lazy val `microsite` = project.in(file("doc/microsite")) "dev.zio" %% "zio-interop-cats" % V.zio_interop_cats excludeAll("dev.zio" %% "izumi-reflect"), "dev.zio" %% "izumi-reflect" % V.izumi_reflect, "org.tpolecat" %% "doobie-core" % V.doobie, - "org.tpolecat" %% "doobie-postgres" % V.doobie + "org.tpolecat" %% "doobie-postgres" % V.doobie, + "io.circe" %% "circe-generic" % V.circe ), libraryDependencies ++= { if (scalaVersion.value.startsWith("2.")) Seq( compilerPlugin("org.typelevel" % "kind-projector" % V.kind_projector cross CrossVersion.full) @@ -4695,9 +4698,7 @@ lazy val `izumi` = (project in file(".")) ThisBuild / developers := List( Developer(id = "7mind", name = "Septimal Mind", url = url("https://github.com/7mind"), email = "team@7mind.io"), ), - ThisBuild / scmInfo := Some(ScmInfo(url("https://github.com/7mind/izumi"), "scm:git:https://github.com/7mind/izumi.git")), - ThisBuild / libraryDependencySchemes += "io.circe" %% "circe-core" % VersionScheme.Always, - ThisBuild / libraryDependencySchemes += "io.circe" %% "circe-core_sjs1" % VersionScheme.Always + ThisBuild / scmInfo := Some(ScmInfo(url("https://github.com/7mind/izumi"), "scm:git:https://github.com/7mind/izumi.git")) ) .disablePlugins(AssemblyPlugin) .aggregate( diff --git a/doc/microsite/src/main/scala/com/example/Entity.scala b/doc/microsite/src/main/scala/com/example/Entity.scala index 852184f2d3..06c1141814 100644 --- a/doc/microsite/src/main/scala/com/example/Entity.scala +++ b/doc/microsite/src/main/scala/com/example/Entity.scala @@ -6,5 +6,5 @@ import io.circe.Encoder final case class Entity(id: UUID) object Entity { - implicit val enc: Encoder.AsObject[Entity] = io.circe.derivation.deriveEncoder[Entity] + implicit val enc: Encoder.AsObject[Entity] = io.circe.generic.semiauto.deriveEncoder[Entity] } diff --git a/doc/microsite/src/main/tut/logstage/00_logstage.md b/doc/microsite/src/main/tut/logstage/00_logstage.md index 3219dc43b2..473089a373 100644 --- a/doc/microsite/src/main/tut/logstage/00_logstage.md +++ b/doc/microsite/src/main/tut/logstage/00_logstage.md @@ -323,14 +323,14 @@ Example: ```scala mdoc:reset:to-string import io.circe.Codec -import io.circe.derivation +import io.circe.generic.semiauto import logstage.LogstageCodec import logstage.circe.LogstageCirceCodec final case class KV(key: String, value: Int) object KV { - implicit val circeCodec: Codec[KV] = derivation.deriveCodec[KV] + implicit val circeCodec: Codec[KV] = semiauto.deriveCodec[KV] implicit val logstageCodec: LogstageCodec[KV] = LogstageCirceCodec.derived[KV] } ``` @@ -394,4 +394,4 @@ You might need to do the following in order for the adapter to properly initiali ```scala SLF4JBridgeHandler.removeHandlersForRootLogger() SLF4JBridgeHandler.install() -``` \ No newline at end of file +``` diff --git a/fundamentals/fundamentals-reflection/src/main/scala-2/izumi/fundamentals/reflection/CirceTool.scala b/fundamentals/fundamentals-json-circe/src/main/scala-2/izumi/fundamentals/json/circe/CirceTool.scala similarity index 98% rename from fundamentals/fundamentals-reflection/src/main/scala-2/izumi/fundamentals/reflection/CirceTool.scala rename to fundamentals/fundamentals-json-circe/src/main/scala-2/izumi/fundamentals/json/circe/CirceTool.scala index 78fc1bf7d9..8639027e85 100644 --- a/fundamentals/fundamentals-reflection/src/main/scala-2/izumi/fundamentals/reflection/CirceTool.scala +++ b/fundamentals/fundamentals-json-circe/src/main/scala-2/izumi/fundamentals/json/circe/CirceTool.scala @@ -1,4 +1,4 @@ -package izumi.fundamentals.reflection +package izumi.fundamentals.json.circe import scala.collection.mutable import scala.language.experimental.macros @@ -9,7 +9,7 @@ object CirceTool { } class CirceToolMacro(val c: blackbox.Context) { - import c.universe._ + import c.universe.* @inline def make[T: c.WeakTypeTag](): c.Expr[Unit] = { val all = new mutable.HashSet[Type]() diff --git a/fundamentals/fundamentals-json-circe/src/main/scala-2/izumi/fundamentals/json/circe/MaterializeDerivationMacros.scala b/fundamentals/fundamentals-json-circe/src/main/scala-2/izumi/fundamentals/json/circe/MaterializeDerivationMacros.scala index 9fc170d936..25d2429ced 100644 --- a/fundamentals/fundamentals-json-circe/src/main/scala-2/izumi/fundamentals/json/circe/MaterializeDerivationMacros.scala +++ b/fundamentals/fundamentals-json-circe/src/main/scala-2/izumi/fundamentals/json/circe/MaterializeDerivationMacros.scala @@ -1,13 +1,12 @@ package izumi.fundamentals.json.circe -import io.circe.derivation.DerivationMacros import io.circe.{Codec, Decoder, Encoder} import scala.language.experimental.macros import scala.reflect.macros.blackbox // TODO: merge upstream, also with @JsonCodec -final class MaterializeDerivationMacros(override val c: blackbox.Context) extends DerivationMacros(c) { +final class MaterializeDerivationMacros(val c: blackbox.Context) { import c.universe.* def materializeEncoderImpl[A: c.WeakTypeTag]: c.Expr[DerivationDerivedEncoder[A]] = diff --git a/fundamentals/fundamentals-json-circe/src/main/scala-2/izumi/fundamentals/json/circe/WithCirce.scala b/fundamentals/fundamentals-json-circe/src/main/scala-2/izumi/fundamentals/json/circe/WithCirce.scala index b8048a00b2..38124b8a1a 100644 --- a/fundamentals/fundamentals-json-circe/src/main/scala-2/izumi/fundamentals/json/circe/WithCirce.scala +++ b/fundamentals/fundamentals-json-circe/src/main/scala-2/izumi/fundamentals/json/circe/WithCirce.scala @@ -3,6 +3,9 @@ package izumi.fundamentals.json.circe import io.circe.Codec /** + * Requires library dependency on `"io.circe" %% "circe-derivation" % "0.13.0-M5"` + * or later (NOT brought in as a dependency automatically) + * * Provides circe codecs for case classes and sealed traits * * {{{ @@ -38,6 +41,3 @@ abstract class WithCirce[A]()(implicit derivedCodec: DerivationDerivedCodec[A]) implicit val codec: Codec.AsObject[A] = derivedCodec.value } - - - diff --git a/fundamentals/fundamentals-json-circe/src/main/scala/izumi/fundamentals/json/flat/JsonFlattener.scala b/fundamentals/fundamentals-json-circe/src/main/scala/izumi/fundamentals/json/flat/JsonFlattener.scala index 57cc6cdc06..0f92b71d24 100644 --- a/fundamentals/fundamentals-json-circe/src/main/scala/izumi/fundamentals/json/flat/JsonFlattener.scala +++ b/fundamentals/fundamentals-json-circe/src/main/scala/izumi/fundamentals/json/flat/JsonFlattener.scala @@ -7,8 +7,8 @@ import izumi.functional.IzEither.EitherBiAggregate import scala.annotation.switch import scala.collection.mutable.ArrayBuffer import scala.util.control.NonFatal -import JsonFlattener._ -import PathElement._ +import JsonFlattener.* +import PathElement.* import izumi.fundamentals.platform.strings.IzEscape class JsonFlattener { diff --git a/project/Deps.sc b/project/Deps.sc index 0471e3b3a0..01244c5244 100644 --- a/project/Deps.sc +++ b/project/Deps.sc @@ -77,9 +77,7 @@ object Izumi { final val circe_parser = Library("io.circe", "circe-parser", V.circe, LibraryType.Auto) final val circe_literal = Library("io.circe", "circe-literal", V.circe, LibraryType.Auto) final val circe_generic = Library("io.circe", "circe-generic", V.circe, LibraryType.Auto) - final val circe_derivation_scala2 = Library("io.circe", "circe-derivation", V.circe_derivation, LibraryType.Auto) in Scope.Compile.all.scalaVersion( - ScalaVersionScope.AllScala2 - ) + final val circe_derivation_scala2 = Library("io.circe", "circe-derivation", V.circe_derivation, LibraryType.Auto) final val discipline = Library("org.typelevel", "discipline-core", V.discipline, LibraryType.Auto) in Scope.Test.all final val discipline_scalatest = Library("org.typelevel", "discipline-scalatest", V.discipline_scalatest, LibraryType.Auto) in Scope.Test.all @@ -282,11 +280,6 @@ object Izumi { Developer(id = "7mind", name = "Septimal Mind", url = url("https://github.com/7mind"), email = "team@7mind.io"), )""".raw, "scmInfo" in SettingScope.Build := """Some(ScmInfo(url("https://github.com/7mind/izumi"), "scm:git:https://github.com/7mind/izumi.git"))""".raw, -// workaround for: -// java.lang.RuntimeException: found version conflict(s) in library dependencies; some are suspected to be binary incompatible: -// +- io.circe:circe-derivation_2.12:0.13.0-M5 (depends on 0.13.0) - "libraryDependencySchemes" in SettingScope.Build += s""""${circe_core.group}" %% "${circe_core.artifact}" % VersionScheme.Always""".raw, - "libraryDependencySchemes" in SettingScope.Build += s""""${circe_core.group}" %% "${circe_core.artifact}_sjs1" % VersionScheme.Always""".raw, ) final val sharedSettings = Defaults.SbtMetaSharedOptions ++ outOfSource ++ crossScalaSources ++ Seq( @@ -341,6 +334,7 @@ object Izumi { final val typesafeConfig = ArtifactId("fundamentals-typesafe-config") final val reflection = ArtifactId("fundamentals-reflection") final val jsonCirce = ArtifactId("fundamentals-json-circe") + final val jsonCirceLegacy = ArtifactId("fundamentals-json-circe-legacy") final lazy val basics = Seq( platform, @@ -464,15 +458,22 @@ object Izumi { Artifact( name = Projects.fundamentals.jsonCirce, libs = Seq( + scala_reflect, circe_core in Scope.Compile.all, circe_generic in Scope.Compile.all.scalaVersion(ScalaVersionScope.AllScala3), - circe_derivation_scala2, - scala_reflect, ) ++ Seq( + circe_derivation_scala2 in Scope.Test.all.scalaVersion(ScalaVersionScope.AllScala2), jawn in Scope.Test.all, circe_literal in Scope.Test.all, ), depends = Seq(Projects.fundamentals.platform), + settings = Seq( + // workaround for: + // java.lang.RuntimeException: found version conflict(s) in library dependencies; some are suspected to be binary incompatible: + // +- io.circe:circe-derivation_2.12:0.13.0-M5 (depends on 0.13.0) + "libraryDependencySchemes" in SettingScope.Compile += s""""${circe_core.group}" %% "${circe_core.artifact}" % VersionScheme.Always""".raw, + "libraryDependencySchemes" in SettingScope.Compile += s""""${circe_core.group}" %% "${circe_core.artifact}_sjs1" % VersionScheme.Always""".raw, + ), ), Artifact( name = Projects.fundamentals.reflection, @@ -620,13 +621,14 @@ object Izumi { Artifact( name = Projects.logstage.renderingCirce, libs = Seq( + circe_core in Scope.Compile.all, jawn in Scope.Test.all, circe_parser in Scope.Test.all, circe_literal in Scope.Test.all, circe_generic in Scope.Test.all, zio_core in Scope.Test.all, ), - depends = Seq(Projects.fundamentals.jsonCirce).map(_ in Scope.Compile.all) ++ Seq(Projects.logstage.core).map(_ tin Scope.Compile.all), + depends = Seq(Projects.logstage.core).map(_ tin Scope.Compile.all), ), Artifact( name = Projects.logstage.adapterSlf4j, @@ -658,7 +660,9 @@ object Izumi { artifacts = Seq( Artifact( name = Projects.docs.microsite, - libs = (allMonads ++ doobie_all).map(_ in Scope.Compile.all), + libs = (allMonads ++ doobie_all).map(_ in Scope.Compile.all) ++ Seq( + circe_generic in Scope.Compile.all + ), depends = all.flatMap(_.artifacts).map(_.name in Scope.Compile.all).distinct, settings = Seq( // ignore microsite in IDEA