Skip to content

Commit

Permalink
cross publish for Scala 3, except for play-json-generic (#36)
Browse files Browse the repository at this point in the history
* cross publish for Scala 3, except for play-json-generic

* update Scala.js to 1.16.0 to be able to build for Scala 2.13.14

---------

Co-authored-by: jmast <jmast@evolution.com>
  • Loading branch information
johanmast and jmast authored May 8, 2024
1 parent d894ccf commit 24f1f6c
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 17 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
strategy:
matrix:
scala:
- 2.13.12
- 2.12.18
- 3.3.1
- 2.13.14
- 2.12.19
- 3.3.3

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
3. `play-json-jsoniter` — provides the fastest way to convert an instance of `play.api.libs.json.JsValue` to byte array and read it back.
4. `play-json-circe` — provides conversions to/from `circe` codecs to ease transitions from one library to another. Examples in [CirceToPlayConversionsSpec](play-json-circe/src/test/scala/com/evolution/playjson/circe/CirceToPlayConversionsSpec.scala) and [PlayToCirceConversionsSpec](play-json-circe/src/test/scala/com/evolution/playjson/circe/PlayToCirceConversionsSpec.scala).

All modules are available for Scala 2.12, 2.13 and 3, except for `play-json-generic`, which has no Scala 3 version yet.

## Setup

```scala
Expand Down
12 changes: 6 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Dependencies._
import ReleaseTransformations._

val Scala213 = "2.13.12"
val Scala212 = "2.12.18"
val Scala3 = "3.3.1"
val Scala213 = "2.13.14"
val Scala212 = "2.12.19"
val Scala3 = "3.3.3"

val commonSettings = Seq(
homepage := Some(new URL("https://github.com/evolution-gaming/play-json-tools")),
Expand All @@ -16,7 +16,7 @@ val commonSettings = Seq(
description := "Set of implicit helper classes for transforming various objects to and from JSON",
startYear := Some(2017),
scalaVersion := Scala213,
crossScalaVersions := Seq(scalaVersion.value, Scala212),
crossScalaVersions := Seq(scalaVersion.value, Scala212, Scala3),
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v >= 13 =>
Expand Down Expand Up @@ -72,12 +72,13 @@ lazy val `play-json-generic` = crossProject(JVMPlatform, JSPlatform)
.crossType(CrossType.Pure)
.settings(
commonSettings,
crossScalaVersions -= Scala3,
scalacOptsFailOnWarn := Some(false),
libraryDependencies ++= Seq(
shapeless,
playJson,
scalaTest % Test
).map(excludeLog4j)
).map(excludeLog4j),
)

lazy val `play-json-tools` = project
Expand All @@ -98,7 +99,6 @@ lazy val `play-json-jsoniter` = crossProject(JVMPlatform, JSPlatform)
.crossType(CrossType.Full)
.settings(
commonSettings,
crossScalaVersions := crossScalaVersions.value ++ Seq(Scala3),
libraryDependencies ++= (Seq(
playJson,
jsoniter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object PlayCirceAstConversions {
json.flatMap(_.fold(
jsonNull = Eval.now(PlayJson.JsNull),
jsonBoolean = b => Eval.now(PlayJson.JsBoolean(b)),
jsonNumber = n => Eval.now(n.toBigDecimal.map(PlayJson.JsNumber).getOrElse(PlayJson.JsNumber(n.toDouble))),
jsonNumber = n => Eval.now(n.toBigDecimal.map(PlayJson.JsNumber.apply).getOrElse(PlayJson.JsNumber(n.toDouble))),
jsonString = s => Eval.now(PlayJson.JsString(s)),
jsonArray = as =>
Eval
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.evolution.playjson.tools
import com.evolutiongaming.nel.Nel
import play.api.libs.json._

import java.net.URL
import java.net.{URI, URL}
import java.time.format.{DateTimeFormatter, DateTimeParseException}
import java.time.{Instant, LocalTime, ZoneOffset}
import scala.concurrent.duration._
Expand All @@ -17,7 +17,7 @@ object PlayJsonHelper {

def reads(json: JsValue): JsResult[URL] = for {
s <- json.validate[String]
url <- Try(new URL(s)) match {
url <- Try(new URI(s).toURL) match {
case Success(x) => JsSuccess(x)
case Failure(t) => JsError(t.toString)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.evolution.playjson.tools

import com.evolution.playjson.tools.FlatFormatSpec.{Inner, Outer}
import com.evolution.playjson.tools.PlayJsonHelper.FlatFormat
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
Expand Down Expand Up @@ -30,13 +31,17 @@ class FlatFormatSpec extends AnyFunSuite with Matchers {
FlatFormat("inner2", Json.format[Outer])
}
}
}

object FlatFormatSpec {
case class Inner(inner: String)

object Inner {
implicit val JsonFormat: Format[Inner] = Json.format[Inner]
}

case class Outer(outer: String, inner: Inner)

object Outer {
implicit val JsonFormat: Format[Outer] = FlatFormat("inner", Json.format[Outer])
}
Expand Down
4 changes: 2 additions & 2 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import sbt._
object Dependencies {

val shapeless = "com.chuusai" %% "shapeless" % "2.3.10"
val nel = "com.evolutiongaming" %% "nel" % "1.3.4"
val nel = "com.evolutiongaming" %% "nel" % "1.3.5"
val playJson = "com.typesafe.play" %% "play-json" % "2.10.2"
val scalaTest = "org.scalatest" %% "scalatest" % "3.2.15"
val scalaTest = "org.scalatest" %% "scalatest" % "3.2.18"
val jsoniter = "com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-core" % "2.23.0"
val jsonGenerator = "com.github.imrafaelmerino" %% "json-scala-values-generator" % "1.0.0"
val collectionCompact = "org.scala-lang.modules" %% "scala-collection-compat" % "2.10.0"
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.10.0
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
externalResolvers += Resolver.bintrayIvyRepo("evolutiongaming", "sbt-plugins")

val scalaJSVersion = Option(System.getenv("SCALAJS_VERSION")).getOrElse("1.13.0")
val scalaJSVersion = Option(System.getenv("SCALAJS_VERSION")).getOrElse("1.16.0")

addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")

addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion)

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.9")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.12")

addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.3.11")

Expand Down

0 comments on commit 24f1f6c

Please sign in to comment.