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

Dependencies updates #591

Merged
merged 19 commits into from
Nov 18, 2023
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
fail-fast: false
matrix:
java: ['adopt@1.8', 'adopt@1.11']
scala: ['2.12.17', '2.13.8', '3.2.1']
scala: ['2.12.18', '2.13.12', '3.3.1']
steps:
- uses: actions/checkout@v3.0.0
with:
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ import zio.stream._
import zio.schema.codec.{BinaryCodec, ProtobufCodec}
import zio.schema.{DeriveSchema, Schema}

import java.io.IOException

final case class Person(name: String, age: Int)

object Person {
Expand All @@ -71,7 +73,7 @@ object Person {
}

object Main extends ZIOAppDefault {
def run =
def run: ZIO[Any, IOException, Unit] =
ZStream
.succeed(Person("John", 43))
.via(Person.protobufCodec.streamEncoder)
Expand Down
9 changes: 5 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ lazy val zioSchemaThrift = crossProject(JSPlatform, JVMPlatform)
.settings(buildInfoSettings("zio.schema.thrift"))
.settings(
libraryDependencies ++= Seq(
"org.apache.thrift" % "libthrift" % "0.16.0"
"org.apache.thrift" % "libthrift" % thriftVersion,
"javax.annotation" % "javax.annotation-api" % javaxAnnotationApiVersion
)
)

Expand All @@ -208,9 +209,9 @@ lazy val zioSchemaMsgPack = crossProject(JSPlatform, JVMPlatform)
.settings(buildInfoSettings("zio.schema.msgpack"))
.settings(
libraryDependencies ++= Seq(
"org.msgpack" % "msgpack-core" % "0.9.3",
"org.msgpack" % "jackson-dataformat-msgpack" % "0.9.3" % Test,
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.13.2" % Test
"org.msgpack" % "msgpack-core" % msgpackVersion,
"org.msgpack" % "jackson-dataformat-msgpack" % msgpackVersion % Test,
"com.fasterxml.jackson.module" %% "jackson-module-scala" % jacksonScalaVersion % Test
)
)

Expand Down
2 changes: 1 addition & 1 deletion docs/derivations/optics-derivation.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ import zio.schema.Schema._
import zio.schema._

object IntList {
implicit val listschema =
implicit val listschema: Schema.Sequence[List[Int], Int, String] =
Sequence[List[Int], Int, String](
elementSchema = Schema[Int],
fromChunk = _.toList,
Expand Down
73 changes: 38 additions & 35 deletions docs/examples/mapping-dto-to-domain-object.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import java.time.LocalDate
object MainApp extends ZIOAppDefault {

case class PersonDTO(
firstName: String,
lastName: String,
birthday: (Int, Int, Int)
)
firstName: String,
lastName: String,
birthday: (Int, Int, Int)
)

object PersonDTO {
implicit val schema: Schema[PersonDTO] = DeriveSchema.gen[PersonDTO]
Expand Down Expand Up @@ -71,27 +71,29 @@ object MainApp extends ZIOAppDefault {
|}
|""".stripMargin

def run = for {
// Approach 1: Decode JSON String to PersonDTO and then Transform it into the Person object
personDTO <- ZIO.fromEither(JsonCodec[PersonDTO].decodeJson(json))
(year, month, day) = personDTO.birthday
person1 = Person(
name = personDTO.firstName + " " + personDTO.lastName,
LocalDate.of(year, month, day)
)
_ <- ZIO.debug(
s"person: $person1"
)

// Approach 2: Decode JSON string in one step into the Person object
person2 <- ZIO.fromEither(
JsonCodec[Person](Person.personDTOJsonMapperCodec).decodeJson(json)
)
_ <- ZIO.debug(
s"person: $person2"
)
} yield assert(person1 == person2)
def run: zio.ZIO[Any, String, Any] =
for {
// Approach 1: Decode JSON String to PersonDTO and then Transform it into the Person object
personDTO <- ZIO.fromEither(JsonCodec[PersonDTO].decodeJson(json))
(year, month, day) = personDTO.birthday
person1 = Person(
name = personDTO.firstName + " " + personDTO.lastName,
LocalDate.of(year, month, day)
)
_ <- ZIO.debug(
s"person: $person1"
)

// Approach 2: Decode JSON string in one step into the Person object
person2 <- ZIO.fromEither(
JsonCodec[Person](Person.personDTOJsonMapperCodec).decodeJson(json)
)
_ <- ZIO.debug(
s"person: $person2"
)
} yield assert(person1 == person2)
}

```

As we can see in the example above, the second approach is much simpler and more convenient than the first one.
Expand All @@ -111,10 +113,10 @@ import java.time.LocalDate
object MainApp extends ZIOAppDefault {

case class PersonDTO(
firstName: String,
lastName: String,
birthday: (Int, Int, Int)
)
firstName: String,
lastName: String,
birthday: (Int, Int, Int)
)

object PersonDTO {
implicit val schema: Schema[PersonDTO] = DeriveSchema.gen[PersonDTO]
Expand Down Expand Up @@ -152,16 +154,17 @@ object MainApp extends ZIOAppDefault {
ZIO.fromEither(
PersonDTO.schema
.migrate(personDTOMapperSchema)
.flatMap(_ (p))
.flatMap(_(p))
)
}


def run = for {
personDTO <- ZIO.succeed(PersonDTO("John", "Doe", (1981, 7, 13)))
person <- Person.fromPersonDTO(personDTO)
_ <- ZIO.debug(s"person: $person")
} yield ()
def run: zio.ZIO[Any, String, Any] =
for {
personDTO <- ZIO.succeed(PersonDTO("John", "Doe", (1981, 7, 13)))
person <- Person.fromPersonDTO(personDTO)
_ <- ZIO.debug(s"person: $person")
} yield ()

}

```
4 changes: 3 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ import zio.stream._
import zio.schema.codec.{BinaryCodec, ProtobufCodec}
import zio.schema.{DeriveSchema, Schema}

import java.io.IOException

final case class Person(name: String, age: Int)

object Person {
Expand All @@ -71,7 +73,7 @@ object Person {
}

object Main extends ZIOAppDefault {
def run =
def run: ZIO[Any, IOException, Unit] =
ZStream
.succeed(Person("John", 43))
.via(Person.protobufCodec.streamEncoder)
Expand Down
2 changes: 1 addition & 1 deletion docs/integration-with-zio-streams.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object Main extends ZIOAppDefault {
implicit val schema: Schema[Person] = DeriveSchema.gen[Person]
}

def run =
def run: ZIO[Any, Exception, Unit] =
ZStream
.fromIterable(Seq(Person("John", 42)))
.debug("the input object is")
Expand Down
2 changes: 1 addition & 1 deletion docs/operations/dynamic-data-representation.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import zio.schema._
case class Person(name: String, age: Int)

object Person {
implicit val schema = DeriveSchema.gen[Person]
implicit val schema: Schema[Person] = DeriveSchema.gen[Person]
}

val person = Person("John Doe", 42)
Expand Down
2 changes: 1 addition & 1 deletion docs/operations/validating-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import zio.schema.validation.Validation
case class Person(name: String, age: Int)

object Person {
implicit val schema = CaseClass2(
implicit val schema: Schema[Person] = CaseClass2(
id0 = TypeId.fromTypeName("Person"),
field01 = Schema.Field(
name0 = "name",
Expand Down
38 changes: 21 additions & 17 deletions project/BuildHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,26 @@ object BuildHelper {

val Scala212: String = versions("2.12")
val Scala213: String = versions("2.13")
val Scala3: String = versions("3.2") //versions.getOrElse("3.0", versions("3.1"))
val Scala3: String = versions("3.3")

val zioVersion = "2.0.10"
val zioJsonVersion = "0.5.0"
val zioPreludeVersion = "1.0.0-RC18"
val zioVersion = "2.0.19"
val zioJsonVersion = "0.6.2"
val zioPreludeVersion = "1.0.0-RC21"
val zioOpticsVersion = "0.2.1"
val zioBsonVersion = "1.0.2"
val silencerVersion = "1.7.11"
val avroVersion = "1.11.0"
val bsonVersion = "4.9.1"
val zioBsonVersion = "1.0.5"
val silencerVersion = "1.7.14"
val avroVersion = "1.11.3"
val bsonVersion = "4.11.1"
val zioConstraintlessVersion = "0.3.2"
val scalaCollectionCompatVersion = "2.10.0"
val msgpackVersion = "0.9.6"
val jacksonScalaVersion = "2.15.2"
val thriftVersion = "0.16.0"
val javaxAnnotationApiVersion = "1.3.2"

private val testDeps = Seq(
"dev.zio" %% "zio-test" % zioVersion % "test",
"dev.zio" %% "zio-test-sbt" % zioVersion % "test"
"dev.zio" %% "zio-test" % zioVersion % Test,
"dev.zio" %% "zio-test-sbt" % zioVersion % Test
)

def macroDefinitionSettings = Seq(
Expand All @@ -47,8 +51,8 @@ object BuildHelper {
if (scalaVersion.value == Scala3) Seq()
else
Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided",
"org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided"
"org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided,
"org.scala-lang" % "scala-compiler" % scalaVersion.value % Provided
)
}
)
Expand Down Expand Up @@ -119,18 +123,19 @@ object BuildHelper {
"-opt-warnings",
"-Ywarn-extra-implicit",
"-Ywarn-unused",
"-Ymacro-annotations"
"-Ymacro-annotations",
"-Ywarn-macros:after"
) ++ std2xOptions ++ optimizerOptions
case Some((2, 12)) =>
Seq(
"-Ypartial-unification",
"-opt-warnings",
"-Ywarn-extra-implicit",
"-Ywarn-unused",
"-Yno-adapted-args",
"-Ywarn-inaccessible",
"-Ywarn-nullary-override",
"-Ywarn-nullary-unit"
"-Ywarn-nullary-unit",
"-Wconf:cat=unused-nowarn:s"
) ++ std2xOptions ++ optimizerOptions
case _ => Seq.empty
}
Expand Down Expand Up @@ -205,8 +210,7 @@ object BuildHelper {
ThisBuild / semanticdbVersion := scalafixSemanticdb.revision,
ThisBuild / scalafixScalaBinaryVersion := CrossVersion.binaryScalaVersion(scalaVersion.value),
ThisBuild / scalafixDependencies ++= List(
"com.github.liancheng" %% "organize-imports" % "0.6.0",
"com.github.vovapolu" %% "scaluzzi" % "0.1.21"
"com.github.vovapolu" %% "scaluzzi" % "0.1.23"
),
Test / parallelExecution := !sys.env.contains("CI"),
incOptions ~= (_.withLogRecompileOnMacro(true)),
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.8.2
sbt.version=1.9.7
16 changes: 8 additions & 8 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.5")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.1")
addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.10")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.13.1")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.0")
addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.3.1")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.14.0")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.2")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.11")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.1.0")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.4")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.3.2")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.16")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.6")
addSbtPlugin("dev.zio" % "zio-sbt-website" % "0.3.10")

libraryDependencies += "org.snakeyaml" % "snakeyaml-engine" % "2.5"
libraryDependencies += "org.snakeyaml" % "snakeyaml-engine" % "2.7"
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ object AccessorBuilderSpec extends ZIOSpecDefault {
check(SchemaGen.anyPrimitive) { schema =>
val transform = schema.transformOrFail[Unit](_ => Left("error"), _ => Left("error"))

val transformAccessor: Any = transform.makeAccessors(builder).asInstanceOf[Any]
val schemaAccessor: Any = schema.makeAccessors(builder).asInstanceOf[Any]
val transformAccessor = transform.makeAccessors(builder)
val schemaAccessor = schema.makeAccessors(builder)

assert(
transformAccessor == schemaAccessor
Expand Down
3 changes: 2 additions & 1 deletion tests/shared/src/test/scala/zio/schema/SchemaSpec.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package zio.schema

import scala.annotation.nowarn
import scala.collection.immutable.ListMap

import zio.Chunk
Expand Down Expand Up @@ -64,7 +65,7 @@ object SchemaSpec extends ZIOSpecDefault {
)
)

def schemaEnum(key: String): Schema[Any] =
@nowarn def schemaEnum(key: String): Schema[Any] =
Schema.enumeration[Any, CaseSet.Aux[Any]](
TypeId.Structural,
caseOf[Unit, Any](key)(_ => ())(_.asInstanceOf[CaseSet.Aux[Any]])(
Expand Down
Loading
Loading