|
| 1 | +import org.typelevel.sbt.tpolecat.DevMode |
| 2 | +import org.typelevel.sbt.tpolecat.OptionsMode |
| 3 | +import java.net.URI |
| 4 | + |
| 5 | +inThisBuild( |
| 6 | + List( |
| 7 | + organization := "tech.neander", |
| 8 | + homepage := Some(url("https://github.com/neandertech/jsonrpclib")), |
| 9 | + licenses := List(License.Apache2), |
| 10 | + developers := List( |
| 11 | + Developer( "Baccata", "Olivier Mélois", "[email protected]", URI.create( "https://github.com/baccata").toURL) |
| 12 | + ), |
| 13 | + sonatypeCredentialHost := "s01.oss.sonatype.org", |
| 14 | + sonatypeRepository := "https://s01.oss.sonatype.org/service/local" |
| 15 | + ) |
| 16 | +) |
| 17 | + |
| 18 | +val scala213 = "2.13.16" |
| 19 | +val scala3 = "3.3.5" |
| 20 | +val allScalaVersions = List(scala213, scala3) |
| 21 | +val jvmScalaVersions = allScalaVersions |
| 22 | +val jsScalaVersions = allScalaVersions |
| 23 | +val nativeScalaVersions = allScalaVersions |
| 24 | + |
| 25 | +val fs2Version = "3.12.0" |
| 26 | + |
| 27 | +ThisBuild / tpolecatOptionsMode := DevMode |
| 28 | + |
| 29 | +val commonSettings = Seq( |
| 30 | + libraryDependencies ++= Seq( |
| 31 | + "com.disneystreaming" %%% "weaver-cats" % "0.8.4" % Test |
| 32 | + ), |
| 33 | + mimaPreviousArtifacts := Set( |
| 34 | + organization.value %%% name.value % "0.0.7" |
| 35 | + ), |
| 36 | + scalacOptions += "-java-output-version:8" |
| 37 | +) |
| 38 | + |
| 39 | +val core = projectMatrix |
| 40 | + .in(file("modules") / "core") |
| 41 | + .jvmPlatform( |
| 42 | + jvmScalaVersions, |
| 43 | + Test / unmanagedSourceDirectories ++= Seq( |
| 44 | + (projectMatrixBaseDirectory.value / "src" / "test" / "scalajvm-native").getAbsoluteFile |
| 45 | + ) |
| 46 | + ) |
| 47 | + .jsPlatform(jsScalaVersions) |
| 48 | + .nativePlatform( |
| 49 | + nativeScalaVersions, |
| 50 | + Test / unmanagedSourceDirectories ++= Seq( |
| 51 | + (projectMatrixBaseDirectory.value / "src" / "test" / "scalajvm-native").getAbsoluteFile |
| 52 | + ) |
| 53 | + ) |
| 54 | + .disablePlugins(AssemblyPlugin) |
| 55 | + .settings( |
| 56 | + name := "jsonrpclib-core", |
| 57 | + commonSettings, |
| 58 | + libraryDependencies ++= Seq( |
| 59 | + "com.github.plokhotnyuk.jsoniter-scala" %%% "jsoniter-scala-macros" % "2.30.2" |
| 60 | + ) |
| 61 | + ) |
| 62 | + |
| 63 | +val fs2 = projectMatrix |
| 64 | + .in(file("modules") / "fs2") |
| 65 | + .jvmPlatform(jvmScalaVersions) |
| 66 | + .jsPlatform(jsScalaVersions) |
| 67 | + .nativePlatform(nativeScalaVersions) |
| 68 | + .disablePlugins(AssemblyPlugin) |
| 69 | + .dependsOn(core) |
| 70 | + .settings( |
| 71 | + name := "jsonrpclib-fs2", |
| 72 | + commonSettings, |
| 73 | + libraryDependencies ++= Seq( |
| 74 | + "co.fs2" %%% "fs2-core" % fs2Version |
| 75 | + ) |
| 76 | + ) |
| 77 | + |
| 78 | +val exampleServer = projectMatrix |
| 79 | + .in(file("modules") / "examples/server") |
| 80 | + .jvmPlatform(List(scala213)) |
| 81 | + .dependsOn(fs2) |
| 82 | + .settings( |
| 83 | + commonSettings, |
| 84 | + publish / skip := true, |
| 85 | + libraryDependencies ++= Seq( |
| 86 | + "co.fs2" %%% "fs2-io" % fs2Version |
| 87 | + ) |
| 88 | + ) |
| 89 | + .disablePlugins(MimaPlugin) |
| 90 | + |
| 91 | +val exampleClient = projectMatrix |
| 92 | + .in(file("modules") / "examples/client") |
| 93 | + .jvmPlatform( |
| 94 | + List(scala213), |
| 95 | + Seq( |
| 96 | + fork := true, |
| 97 | + envVars += "SERVER_JAR" -> (exampleServer.jvm(scala213) / assembly).value.toString |
| 98 | + ) |
| 99 | + ) |
| 100 | + .disablePlugins(AssemblyPlugin) |
| 101 | + .dependsOn(fs2) |
| 102 | + .settings( |
| 103 | + commonSettings, |
| 104 | + publish / skip := true, |
| 105 | + libraryDependencies ++= Seq( |
| 106 | + "co.fs2" %%% "fs2-io" % fs2Version |
| 107 | + ) |
| 108 | + ) |
| 109 | + .disablePlugins(MimaPlugin) |
| 110 | + |
| 111 | +val root = project |
| 112 | + .in(file(".")) |
| 113 | + .settings( |
| 114 | + publish / skip := true |
| 115 | + ) |
| 116 | + .disablePlugins(MimaPlugin, AssemblyPlugin) |
| 117 | + .aggregate(List(core, fs2, exampleServer, exampleClient).flatMap(_.projectRefs): _*) |
| 118 | + |
| 119 | +// The core compiles are a workaround for https://github.com/plokhotnyuk/jsoniter-scala/issues/564 |
| 120 | +// when we switch to SN 0.5, we can use `makeWithSkipNestedOptionValues` instead: https://github.com/plokhotnyuk/jsoniter-scala/issues/564#issuecomment-2787096068 |
| 121 | +val compileCoreModules = { |
| 122 | + for { |
| 123 | + scalaVersionSuffix <- List("", "3") |
| 124 | + platformSuffix <- List("", "JS", "Native") |
| 125 | + task <- List("compile", "package") |
| 126 | + } yield s"core$platformSuffix$scalaVersionSuffix/$task" |
| 127 | +}.mkString(";") |
| 128 | + |
| 129 | +addCommandAlias( |
| 130 | + "ci", |
| 131 | + s"$compileCoreModules;test;scalafmtCheckAll;mimaReportBinaryIssues" |
| 132 | +) |
0 commit comments