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

Update for Scala 3 #206

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.7, 2.12.12]
scala: [3.2.2, 2.13.10, 2.12.17]
java: [[email protected]]
runs-on: ${{ matrix.os }}
steps:
Expand Down
69 changes: 35 additions & 34 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
ThisBuild / organization := "io.circe"
ThisBuild / crossScalaVersions := Seq("2.12.15", "2.13.6")
ThisBuild / githubWorkflowPublishTargetBranches := Nil
ThisBuild / githubWorkflowJobSetup := {
(ThisBuild / githubWorkflowJobSetup).value.toList.map {
Expand All @@ -25,47 +24,42 @@ val compilerOptions = Seq(
"-feature",
"-language:existentials",
"-language:higherKinds",
"-unchecked",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen"
"-unchecked"
)

val circeVersion = "0.14.1"
val circeVersion = "0.14.5"
val everitVersion = "1.14.0"
val previousCirceJsonSchemaVersion = "0.1.0"

val scala212 = "2.12.12"
val scala213 = "2.13.7"
val scala212 = "2.12.17"
val scala213 = "2.13.10"
val scala3 = "3.2.2"

ThisBuild / crossScalaVersions := Seq(scala213, scala212)

def priorTo2_13(scalaVersion: String): Boolean =
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, minor)) if minor < 13 => true
case _ => false
}
ThisBuild / crossScalaVersions := Seq(scala3, scala213, scala212)

val baseSettings = Seq(
resolvers += "jitpack".at("https://jitpack.io"),
scalacOptions ++= compilerOptions,
scalacOptions ++= (
if (priorTo2_13(scalaVersion.value))
Seq(
"-Xfuture",
"-Yno-adapted-args",
"-Ywarn-unused-import"
)
else
Seq(
"-Ywarn-unused:imports"
)
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((3, _)) => Nil
case Some((2, minor)) if minor >= 13 =>
Seq(
"-Ywarn-unused:imports",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen"
)
case Some((2, minor)) if minor < 13 =>
Seq(
"-Xfuture",
"-Yno-adapted-args",
"-Ywarn-unused-import",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen"
)
case _ => Nil
}
),
Compile / console / scalacOptions ~= {
_.filterNot(Set("-Ywarn-unused-import", "-Ywarn-unused:imports"))
},
Test / console / scalacOptions ~= {
_.filterNot(Set("-Ywarn-unused-import", "-Ywarn-unused:imports"))
},
coverageHighlighting := true,
(Compile / scalastyleSources) ++= (Compile / unmanagedSourceDirectories).value
)
Expand All @@ -74,7 +68,14 @@ val allSettings = baseSettings ++ publishSettings

val docMappingsApiDir = settingKey[String]("Subdirectory in site target directory for API docs")

val root = project.in(file(".")).settings(allSettings).settings(noPublishSettings).aggregate(schema).dependsOn(schema)
val root = project
.in(file("."))
.settings(allSettings)
.settings(
noPublishSettings
)
.aggregate(schema)
.dependsOn(schema)

lazy val schema = project
.in(file("schema"))
Expand All @@ -88,10 +89,10 @@ lazy val schema = project
"io.circe" %% "circe-jawn" % circeVersion % Test,
"io.circe" %% "circe-testing" % circeVersion % Test,
"com.github.everit-org.json-schema" % "org.everit.json.schema" % everitVersion,
"org.scalatest" %% "scalatest-flatspec" % "3.2.11" % Test,
"org.scalatest" %% "scalatest-flatspec" % "3.2.15" % Test,
"org.scalatestplus" %% "scalacheck-1-15" % "3.2.11.0" % Test
),
ghpagesNoJekyll := true,
ghpagesNoJekyll.withRank(KeyRanks.Invisible) := true,
docMappingsApiDir := "api",
addMappingsToSiteDir(Compile / packageDoc / mappings, docMappingsApiDir)
)
Expand All @@ -100,7 +101,7 @@ lazy val publishSettings = Seq(
releaseCrossBuild := true,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
homepage := Some(url("https://github.com/circe/circe-json-schema")),
licenses := Seq("Apache 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
licenses := Seq("Apache 2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0")),
publishMavenStyle := true,
Test / publishArtifact := false,
pomIncludeRepository := { _ =>
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.6.2
sbt.version=1.8.2
2 changes: 1 addition & 1 deletion schema/src/main/scala/io/circe/schema/Schema.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ object Schema {
val iter = value.toIterable.iterator

while (iter.hasNext) {
val (k, v) = iter.next
val (k, v) = iter.next()
map.put(k, v.foldWith(this))
}
new JSONObject(map)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ object ValidationError {
private[schema] def fromEverit(e: ValidationException): NonEmptyList[ValidationError] = {
val builder = List.newBuilder[ValidationError]
fromEveritRecursive(e, builder)
NonEmptyList(fromEveritOne(e), builder.result)
NonEmptyList(fromEveritOne(e), builder.result())
}
}