-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for scala native, switch to typelevel-sbt
Also add typelevel-nix.
- Loading branch information
Showing
6 changed files
with
247 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,189 +1,115 @@ | ||
import sbtcrossproject.{ CrossType, crossProject } | ||
|
||
ThisBuild / organization := "io.circe" | ||
|
||
val compilerOptions = Seq( | ||
"-deprecation", | ||
"-encoding", | ||
"UTF-8", | ||
"-feature", | ||
"-language:existentials", | ||
"-language:higherKinds", | ||
"-unchecked", | ||
"-Ywarn-dead-code", | ||
"-Ywarn-numeric-widen", | ||
"-Yrangepos" | ||
) | ||
val Scala212V = "2.12.15" | ||
val Scala213V = "2.13.7" | ||
|
||
val scala212 = "2.12.15" | ||
val scala213 = "2.13.7" | ||
|
||
val circeVersion = "0.14.2" | ||
val circeVersion = "0.14.3" | ||
val paradiseVersion = "2.1.1" | ||
|
||
val jawnVersion = "1.3.2" | ||
val munitVersion = "0.7.29" | ||
val disciplineMunitVersion = "1.0.9" | ||
|
||
val previousCirceGenericExtrasVersions = Set("0.14.0", "0.14.1") | ||
|
||
def priorTo2_13(scalaVersion: String): Boolean = | ||
CrossVersion.partialVersion(scalaVersion) match { | ||
case Some((2, minor)) if minor < 13 => true | ||
case _ => false | ||
} | ||
|
||
ThisBuild / crossScalaVersions := Seq(scala212, scala213) | ||
ThisBuild / tlBaseVersion := "0.14" | ||
ThisBuild / tlCiReleaseTags := false | ||
|
||
val baseSettings = Seq( | ||
scalacOptions ++= compilerOptions, | ||
scalacOptions ++= ( | ||
if (priorTo2_13(scalaVersion.value)) | ||
Seq( | ||
"-Xfuture", | ||
"-Yno-adapted-args", | ||
"-Ywarn-unused-import", | ||
"-Ypartial-unification" | ||
) | ||
else | ||
Seq( | ||
"-Ymacro-annotations", | ||
"-Ywarn-unused:imports" | ||
ThisBuild / organization := "io.circe" | ||
ThisBuild / crossScalaVersions := List(Scala212V, Scala213V) | ||
ThisBuild / scalaVersion := Scala213V | ||
|
||
ThisBuild / githubWorkflowJavaVersions := Seq("8", "11", "17").map(JavaSpec.temurin) | ||
|
||
ThisBuild / githubWorkflowAddedJobs ++= Seq( | ||
WorkflowJob( | ||
id = "scalafmt", | ||
name = "Scalafmt and Scalastyle", | ||
scalas = List(crossScalaVersions.value.last), | ||
steps = List(WorkflowStep.Checkout) ++ WorkflowStep.SetupJava( | ||
List(githubWorkflowJavaVersions.value.last) | ||
) ++ githubWorkflowGeneratedCacheSteps.value ++ List( | ||
WorkflowStep.Sbt( | ||
List("+scalafmtCheckAll", "scalafmtSbtCheck", "scalastyle"), | ||
name = Some("Scalafmt and Scalastyle tests") | ||
) | ||
) | ||
), | ||
Compile / console / scalacOptions ~= { | ||
_.filterNot(Set("-Ywarn-unused-import", "-Ywarn-unused:imports")) | ||
}, | ||
Test / console / scalacOptions ~= { | ||
_.filterNot(Set("-Ywarn-unused-import", "-Ywarn-unused:imports")) | ||
}, | ||
coverageHighlighting := true, | ||
libraryDependencies ++= Seq( | ||
scalaOrganization.value % "scala-compiler" % scalaVersion.value % Provided, | ||
scalaOrganization.value % "scala-reflect" % scalaVersion.value % Provided | ||
) ++ ( | ||
if (priorTo2_13(scalaVersion.value)) { | ||
Seq( | ||
compilerPlugin(("org.scalamacros" % "paradise" % paradiseVersion).cross(CrossVersion.patch)) | ||
WorkflowJob( | ||
id = "coverage", | ||
name = "Generate coverage report", | ||
scalas = crossScalaVersions.value.filterNot(_.startsWith("3.")).toList, | ||
steps = List(WorkflowStep.Checkout) ++ WorkflowStep.SetupJava( | ||
List(githubWorkflowJavaVersions.value.last) | ||
) ++ githubWorkflowGeneratedCacheSteps.value ++ List( | ||
WorkflowStep.Sbt(List("coverage", "rootJVM/test", "coverageAggregate")), | ||
WorkflowStep.Use( | ||
UseRef.Public( | ||
"codecov", | ||
"codecov-action", | ||
"v2" | ||
), | ||
params = Map( | ||
"flags" -> List("${{matrix.scala}}", "${{matrix.java}}").mkString(",") | ||
) | ||
) | ||
} else Nil | ||
), | ||
coverageEnabled := ( | ||
if (priorTo2_13(scalaVersion.value)) false else coverageEnabled.value | ||
) | ||
) | ||
) | ||
|
||
val allSettings = baseSettings ++ publishSettings | ||
ThisBuild / scalafixScalaBinaryVersion := CrossVersion.binaryScalaVersion(scalaVersion.value) | ||
ThisBuild / scalafixAll / skip := tlIsScala3.value | ||
ThisBuild / ScalafixConfig / skip := tlIsScala3.value | ||
|
||
val docMappingsApiDir = settingKey[String]("Subdirectory in site target directory for API docs") | ||
|
||
lazy val root = | ||
project | ||
.in(file(".")) | ||
.settings(allSettings) | ||
.settings(noPublishSettings) | ||
.aggregate(genericExtrasJVM, genericExtrasJS) | ||
.disablePlugins(MimaPlugin) | ||
tlCrossRootProject.aggregate(genericExtras).enablePlugins(NoPublishPlugin).disablePlugins(ScalafixPlugin) | ||
|
||
lazy val genericExtras = crossProject(JSPlatform, JVMPlatform) | ||
.withoutSuffixFor(JVMPlatform) | ||
lazy val genericExtras = crossProject(JSPlatform, JVMPlatform, NativePlatform) | ||
.crossType(CrossType.Pure) | ||
.in(file("generic-extras")) | ||
.settings(allSettings) | ||
.settings( | ||
moduleName := "circe-generic-extras", | ||
mimaPreviousArtifacts := previousCirceGenericExtrasVersions.map("io.circe" %% "circe-generic-extras" % _), | ||
libraryDependencies ++= Seq( | ||
"io.circe" %%% "circe-generic" % circeVersion, | ||
"io.circe" %%% "circe-literal" % circeVersion % Test, | ||
"io.circe" %%% "circe-testing" % circeVersion % Test, | ||
"org.scalameta" %%% "munit" % munitVersion % Test, | ||
"org.scalameta" %%% "munit-scalacheck" % munitVersion % Test, | ||
"org.typelevel" %%% "discipline-munit" % disciplineMunitVersion % Test, | ||
"org.typelevel" %% "jawn-parser" % jawnVersion % Test | ||
"org.typelevel" %% "jawn-parser" % jawnVersion % Test, | ||
scalaOrganization.value % "scala-compiler" % scalaVersion.value % Provided, | ||
scalaOrganization.value % "scala-reflect" % scalaVersion.value % Provided | ||
) ++ ( | ||
if (scalaBinaryVersion.value == "2.12") { | ||
Seq( | ||
compilerPlugin(("org.scalamacros" % "paradise" % paradiseVersion).cross(CrossVersion.patch)) | ||
) | ||
} else Nil | ||
), | ||
testFrameworks := List(new TestFramework("munit.Framework")), // Override setting so Scalatest is disabled | ||
scalaJSLinkerConfig in Test ~= (_.withModuleKind(ModuleKind.CommonJSModule)), | ||
ghpagesNoJekyll := true, | ||
docMappingsApiDir := "api", | ||
addMappingsToSiteDir(Compile / packageDoc / mappings, docMappingsApiDir) | ||
addMappingsToSiteDir(Compile / packageDoc / mappings, docMappingsApiDir), | ||
scalacOptions ++= { | ||
if (scalaBinaryVersion.value == "2.13") Seq("-Ymacro-annotations") else Seq.empty | ||
}, | ||
coverageHighlighting := true, | ||
coverageEnabled := false | ||
) | ||
.jvmSettings(Test / fork := true) | ||
.jsSettings(coverageEnabled := false) | ||
|
||
lazy val genericExtrasJVM = genericExtras.jvm | ||
lazy val genericExtrasJS = genericExtras.js | ||
|
||
lazy val publishSettings = Seq( | ||
releaseCrossBuild := true, | ||
releasePublishArtifactsAction := PgpKeys.publishSigned.value, | ||
releaseVcsSign := true, | ||
homepage := Some(url("https://github.com/circe/circe-generic-extras")), | ||
licenses := Seq("Apache 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")), | ||
publishMavenStyle := true, | ||
Test / publishArtifact := false, | ||
pomIncludeRepository := { _ => | ||
false | ||
}, | ||
publishTo := { | ||
val nexus = "https://oss.sonatype.org/" | ||
if (isSnapshot.value) | ||
Some("snapshots".at(nexus + "content/repositories/snapshots")) | ||
else | ||
Some("releases".at(nexus + "service/local/staging/deploy/maven2")) | ||
}, | ||
autoAPIMappings := true, | ||
apiURL := Some(url("https://circe.github.io/circe-generic-extras/api/")), | ||
scmInfo := Some( | ||
ScmInfo( | ||
url("https://github.com/circe/circe-generic-extras"), | ||
"scm:git:[email protected]:circe/circe-generic-extras.git" | ||
) | ||
), | ||
developers := List( | ||
Developer( | ||
"travisbrown", | ||
"Travis Brown", | ||
"[email protected]", | ||
url("https://twitter.com/travisbrown") | ||
.jvmSettings( | ||
Test / fork := true, | ||
coverageEnabled := ( | ||
if (scalaBinaryVersion == "2.12") false else coverageEnabled.value | ||
) | ||
) | ||
) | ||
|
||
lazy val noPublishSettings = Seq( | ||
publish := {}, | ||
publishLocal := {}, | ||
publishArtifact := false | ||
) | ||
|
||
credentials ++= ( | ||
for { | ||
username <- Option(System.getenv().get("SONATYPE_USERNAME")) | ||
password <- Option(System.getenv().get("SONATYPE_PASSWORD")) | ||
} yield Credentials( | ||
"Sonatype Nexus Repository Manager", | ||
"oss.sonatype.org", | ||
username, | ||
password | ||
.jsSettings() | ||
.nativeSettings( | ||
tlVersionIntroduced := List("2.12", "2.13").map(_ -> "0.14.3").toMap | ||
) | ||
).toSeq | ||
|
||
ThisBuild / githubWorkflowJavaVersions := Seq("[email protected]") | ||
// No auto-publish atm. Remove this line to generate publish stage | ||
ThisBuild / githubWorkflowPublishTargetBranches := Seq.empty | ||
ThisBuild / githubWorkflowBuild := Seq( | ||
WorkflowStep.Sbt( | ||
List("clean", "coverage", "genericExtras/test", "coverageReport", "scalafmtCheckAll"), | ||
id = None, | ||
name = Some("Test JVM") | ||
), | ||
WorkflowStep.Use( | ||
UseRef.Public("codecov", "codecov-action", "e156083f13aff6830c92fc5faa23505779fbf649"), // v1.2.1 | ||
name = Some("Upload code coverage") | ||
), | ||
WorkflowStep.Sbt( | ||
List("genericExtrasJS/test"), | ||
id = None, | ||
name = Some("Test JS") | ||
) | ||
ThisBuild / homepage := Some(url("https://github.com/circe/circe-generic-extras")) | ||
ThisBuild / licenses := Seq("Apache 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")) | ||
ThisBuild / developers := List( | ||
Developer("travisbrown", "Travis Brown", "[email protected]", url("https://twitter.com/travisbrown")), | ||
Developer("zmccoy", "Zach McCoy", "[email protected]", url("https://twitter.com/zachamccoy")), | ||
Developer("zarthross", "Darren Gibson", "[email protected]", url("https://twitter.com/zarthross")) | ||
) |
Oops, something went wrong.