diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95c3577..6f5e5b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - scala: [2.13.18, 3.3.7] + scala: [3.3.7] java: - temurin@8 - temurin@11 @@ -84,12 +84,12 @@ jobs: run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck - name: Build project - run: sbt '++ ${{ matrix.scala }}' test + run: sbt test - name: Binary compatibility - if: matrix.java == 'temurin@8' - run: sbt '++ ${{ matrix.scala }}' mimaReportBinaryIssues + if: matrix.java == 'temurin@25' + run: sbt mimaReportBinaryIssues - name: Build docs if: matrix.java == 'temurin@25' - run: sbt '++ ${{ matrix.scala }}' docs/mdoc + run: sbt mdoc diff --git a/.jvmopts b/.jvmopts new file mode 100644 index 0000000..7e1a33f --- /dev/null +++ b/.jvmopts @@ -0,0 +1 @@ +-Xmx2G diff --git a/build.sbt b/build.sbt index 3652aeb..700cccd 100644 --- a/build.sbt +++ b/build.sbt @@ -1,9 +1,12 @@ +import scala.util.chaining.* + Global / onChangedBuildSource := ReloadOnSourceChanges lazy val scala213 = "2.13.18" lazy val scala3 = "3.3.7" +lazy val allScalaVersions = Seq(scala213, scala3) -ThisBuild / crossScalaVersions := Seq(scala213, scala3) +ThisBuild / scalaVersion := scala3 // GitHub Actions config val javaVersions = Seq(8, 11, 17, 21, 25).map(v => JavaSpec.temurin(v.toString)) @@ -15,9 +18,10 @@ ThisBuild / githubWorkflowTargetBranches := Seq("master") def isJava(v: Int) = s"matrix.java == '${javaVersions.find(_.version == v.toString).get.render}'" -ThisBuild / githubWorkflowBuild ++= Seq( - WorkflowStep.Sbt(List("mimaReportBinaryIssues"), name = Some("Binary compatibility"), cond = Some(isJava(8))), - WorkflowStep.Sbt(List("docs/mdoc"), name = Some("Build docs"), cond = Some(isJava(25))), +ThisBuild / githubWorkflowBuild := Seq( + WorkflowStep.Run(List("sbt test"), name = Some("Build project")), + WorkflowStep.Run(List("sbt mimaReportBinaryIssues"), name = Some("Binary compatibility"), cond = Some(isJava(25))), + WorkflowStep.Run(List("sbt mdoc"), name = Some("Build docs"), cond = Some(isJava(25))), ) ThisBuild / githubWorkflowPublishTargetBranches := Seq() @@ -29,12 +33,8 @@ def foldScalaV[A](scalaVersion: String)(_213: => A, _3: => A): A = } lazy val baseSettings = Seq( - scalaVersion := scala3, - crossScalaVersions := Seq(scala213, scala3), organization := "typify", version := "13.0.0", - resolvers += "bondlink-maven-repo" at "https://maven.bondlink-cdn.com", - mimaPreviousArtifacts := Set("typify" %%% name.value % "12.0.0"), libraryDependencies ++= foldScalaV(scalaVersion.value)( Seq(compilerPlugin("org.typelevel" %% "kind-projector" % "0.13.4" cross CrossVersion.patch)), Seq(), @@ -52,75 +52,87 @@ lazy val baseSettings = Seq( "-language:implicitConversions" ), licenses += License.Apache2, - publishTo := Some("BondLink S3".at("s3://bondlink-maven-repo")), + publish / skip := true, + mimaFailOnNoPrevious := false, ) -lazy val noPublishSettings = Seq( - publish := {}, - publishLocal := {}, +baseSettings + +lazy val publishSettings = Seq( + publish / skip := false, + publishTo := Some("BondLink S3".at("s3://bondlink-maven-repo")), + resolvers += "bondlink-maven-repo" at "https://maven.bondlink-cdn.com", + mimaPreviousArtifacts := Set(organization.value %%% name.value % "12.0.0"), ) -lazy val root = project.in(file(".")) - .aggregate(( - typify.componentProjects ++ - Seq(circeTypify, json4sTypify, sjsTypify) ++ - (if (System.getProperty("java.version").startsWith("1.8")) Seq() else Seq(playjsonTypify)) - ).map(p => p: ProjectReference):_*) - .settings(baseSettings) - .settings(noPublishSettings) - .disablePlugins(MimaPlugin) +def baseProj( + id: String, + nme: String, + scalaVersions: Seq[String] = allScalaVersions, + includeJVM: Boolean = true, + includeJS: Boolean = true, + includeNative: Boolean = true, +) = + sbt.internal.ProjectMatrix(id, file(id)) + .pipe(p => if (includeJVM) p.jvmPlatform(scalaVersions = scalaVersions) else p) + .pipe(p => if (includeJS) p.jsPlatform(scalaVersions = scalaVersions) else p) + .pipe(p => if (includeNative) p.nativePlatform(scalaVersions = scalaVersions) else p) + .settings(baseSettings ++ Seq(name := nme)) lazy val cats = Def.setting("org.typelevel" %%% "cats-core" % "2.13.0") -lazy val circe = "io.circe" %% "circe-core" % "0.14.15" +lazy val circe = Def.setting("io.circe" %%% "circe-core" % "0.14.15") lazy val formless = Def.setting("com.bondlink" %%% "formless" % "0.8.0") lazy val json4s = "io.github.json4s" %% "json4s-jackson" % "4.1.0" -lazy val playJson = "org.playframework" %% "play-json" % "3.0.6" +lazy val playJson = Def.setting("org.playframework" %%% "play-json" % "3.0.6") lazy val scalacheck = Def.setting("org.scalacheck" %%% "scalacheck" % "1.19.0" % Test) -lazy val typify = crossProject(JSPlatform, JVMPlatform, NativePlatform).in(file("typify")) - .settings(baseSettings) +lazy val typify = baseProj("typify", "typify") + .settings(publishSettings) .settings( - name := "typify", libraryDependencies ++= Seq(cats.value, formless.value, scalacheck.value), ) -lazy val circeTypify = project.in(file("circe-typify")) - .settings(baseSettings) +lazy val circeTypify = baseProj("circe-typify", "circe-typify", includeJS = false, includeNative = false) + .settings(publishSettings) .settings( - name := "circe-typify", - libraryDependencies += circe, + libraryDependencies += circe.value, ) - .dependsOn(typify.jvm % "test->test;compile->compile") + .dependsOn(typify % "test->test;compile->compile") -lazy val json4sTypify = project.in(file("json4s-typify")) - .settings(baseSettings) +lazy val json4sTypify = baseProj("json4s-typify", "json4s-typify", includeJS = false, includeNative = false) + .settings(publishSettings) .settings( - name := "json4s-typify", libraryDependencies += json4s ) - .dependsOn(typify.jvm % "test->test;compile->compile") - -lazy val playjsonTypify = project.in(file("play-json-typify")) - .settings(baseSettings) + .dependsOn(typify % "test->test;compile->compile") + +lazy val playjsonTypify = baseProj( + "play-json-typify", + "play-json-typify", + // play-json is published with Java 11 so we can't compile this project with Java 8 + scalaVersions = { + val jv = sys.props.getOrElse("java.specification.version", "") + if (jv == "1.8" || jv == "8") Seq.empty[String] else allScalaVersions + }, + includeJS = false, + includeNative = false, +) + .settings(publishSettings) .settings( - name := "play-json-typify", - libraryDependencies ++= Seq(cats.value, playJson) + libraryDependencies ++= Seq(cats.value, playJson.value) ) - .dependsOn(typify.jvm % "test->test;compile->compile") + .dependsOn(typify % "test->test;compile->compile") -lazy val sjsTypify = project.in(file("jsdynamic-typify")) - .settings(baseSettings) - .settings(name := "jsdynamic-typify") - .dependsOn(typify.js % "test->test;compile->compile") - .enablePlugins(ScalaJSPlugin) +lazy val sjsTypify = baseProj("jsdynamic-typify", "jsdynamic-typify", includeJVM = false, includeNative = false) + .settings(publishSettings) + .dependsOn(typify % "test->test;compile->compile") -lazy val docs = project.in(file("typify-docs")) +lazy val docs = projectMatrix.in(file("typify-docs")) + .jvmPlatform(scalaVersions = Seq(scala3)) .settings(baseSettings) - .settings(noPublishSettings) .settings( mdocOut := file("."), scalacOptions -= "-Werror", ) - .dependsOn(typify.jvm) + .dependsOn(typify) .enablePlugins(MdocPlugin) - .disablePlugins(MimaPlugin) diff --git a/project/plugins.sbt b/project/plugins.sbt index f044bfe..9fc7b7a 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,8 +1,7 @@ +addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.11.0") addSbtPlugin("com.github.sbt" % "sbt-github-actions" % "0.30.0") addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.5") addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.5") -addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.2") -addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.3.2") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.21.0") addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.5.12") addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.9.0") diff --git a/typify/shared/src/main/scala/typify/AnyParsed.scala b/typify/src/main/scala/typify/AnyParsed.scala similarity index 100% rename from typify/shared/src/main/scala/typify/AnyParsed.scala rename to typify/src/main/scala/typify/AnyParsed.scala diff --git a/typify/shared/src/main/scala/typify/CanParse.scala b/typify/src/main/scala/typify/CanParse.scala similarity index 100% rename from typify/shared/src/main/scala/typify/CanParse.scala rename to typify/src/main/scala/typify/CanParse.scala diff --git a/typify/shared/src/main/scala/typify/Cursor.scala b/typify/src/main/scala/typify/Cursor.scala similarity index 100% rename from typify/shared/src/main/scala/typify/Cursor.scala rename to typify/src/main/scala/typify/Cursor.scala diff --git a/typify/shared/src/main/scala/typify/CursorHistory.scala b/typify/src/main/scala/typify/CursorHistory.scala similarity index 100% rename from typify/shared/src/main/scala/typify/CursorHistory.scala rename to typify/src/main/scala/typify/CursorHistory.scala diff --git a/typify/shared/src/main/scala/typify/CursorOp.scala b/typify/src/main/scala/typify/CursorOp.scala similarity index 100% rename from typify/shared/src/main/scala/typify/CursorOp.scala rename to typify/src/main/scala/typify/CursorOp.scala diff --git a/typify/shared/src/main/scala/typify/Generic.scala b/typify/src/main/scala/typify/Generic.scala similarity index 100% rename from typify/shared/src/main/scala/typify/Generic.scala rename to typify/src/main/scala/typify/Generic.scala diff --git a/typify/shared/src/main/scala/typify/ListOf.scala b/typify/src/main/scala/typify/ListOf.scala similarity index 100% rename from typify/shared/src/main/scala/typify/ListOf.scala rename to typify/src/main/scala/typify/ListOf.scala diff --git a/typify/shared/src/main/scala/typify/Optimize.scala b/typify/src/main/scala/typify/Optimize.scala similarity index 100% rename from typify/shared/src/main/scala/typify/Optimize.scala rename to typify/src/main/scala/typify/Optimize.scala diff --git a/typify/shared/src/main/scala/typify/PVFolder.scala b/typify/src/main/scala/typify/PVFolder.scala similarity index 100% rename from typify/shared/src/main/scala/typify/PVFolder.scala rename to typify/src/main/scala/typify/PVFolder.scala diff --git a/typify/shared/src/main/scala/typify/ParseError.scala b/typify/src/main/scala/typify/ParseError.scala similarity index 100% rename from typify/shared/src/main/scala/typify/ParseError.scala rename to typify/src/main/scala/typify/ParseError.scala diff --git a/typify/shared/src/main/scala/typify/StringOps.scala b/typify/src/main/scala/typify/StringOps.scala similarity index 100% rename from typify/shared/src/main/scala/typify/StringOps.scala rename to typify/src/main/scala/typify/StringOps.scala diff --git a/typify/shared/src/main/scala/typify/Typify.scala b/typify/src/main/scala/typify/Typify.scala similarity index 100% rename from typify/shared/src/main/scala/typify/Typify.scala rename to typify/src/main/scala/typify/Typify.scala diff --git a/typify/shared/src/main/scala/typify/package.scala b/typify/src/main/scala/typify/package.scala similarity index 100% rename from typify/shared/src/main/scala/typify/package.scala rename to typify/src/main/scala/typify/package.scala diff --git a/typify/shared/src/test/scala/typify/AnyCanParseProp.scala b/typify/src/test/scala/typify/AnyCanParseProp.scala similarity index 100% rename from typify/shared/src/test/scala/typify/AnyCanParseProp.scala rename to typify/src/test/scala/typify/AnyCanParseProp.scala diff --git a/typify/shared/src/test/scala/typify/CanParseProp.scala b/typify/src/test/scala/typify/CanParseProp.scala similarity index 100% rename from typify/shared/src/test/scala/typify/CanParseProp.scala rename to typify/src/test/scala/typify/CanParseProp.scala