forked from circe/circe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
884 lines (803 loc) · 28.4 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
import ReleaseTransformations._
import microsites.ExtraMdFileConfig
import microsites.ConfigYml
import sbtcrossproject.{ CrossProject, CrossType }
import scala.xml.{ Elem, Node => XmlNode, NodeSeq => XmlNodeSeq }
import scala.xml.transform.{ RewriteRule, RuleTransformer }
def Scala3 = "3.1.0"
ThisBuild / organization := "io.circe"
ThisBuild / crossScalaVersions := List(Scala3, "2.12.15", "2.13.8")
ThisBuild / scalaVersion := crossScalaVersions.value.last
ThisBuild / githubWorkflowJavaVersions := Seq("8", "11", "17").map(JavaSpec.temurin)
ThisBuild / githubWorkflowPublishTargetBranches := Nil
ThisBuild / githubWorkflowArtifactUpload := false // TODO: Maybe enable this later for efficiency.
ThisBuild / githubWorkflowBuildPreamble +=
WorkflowStep.Use(
UseRef.Public("actions", "setup-node", "v2.4.0"),
name = Some("Setup NodeJS v16"),
params = Map("node-version" -> "16"),
cond = Some("matrix.ci == 'ciNodeJS'")
)
ThisBuild / githubWorkflowBuild := Seq(
WorkflowStep.Sbt(
List(
"clean",
"circeJVM/compile",
"circeJVM/test"
),
id = None,
name = Some("Test JVM (without coverage)"),
cond = Some("${{ matrix.scala == '" + Scala3 + "' }}")
),
WorkflowStep.Sbt(
List(
"clean",
"coverage",
"scalastyle",
"circeJVM/compile",
"circeJVM/test",
"benchmark/test"
),
id = None,
name = Some("Test JVM (with coverage)"),
cond = Some("${{ matrix.scala != '" + Scala3 + "' }}")
),
WorkflowStep.Sbt(
List(
"circeJS/compile",
"circeJS/test"
),
id = None,
name = Some("Test JS")
),
WorkflowStep.Sbt(
List("coverageReport"),
id = None,
name = Some("Coverage"),
cond = Some("${{ matrix.scala != '" + Scala3 + "' }}")
),
WorkflowStep.Use(
UseRef.Public(
"codecov",
"codecov-action",
"v2"
),
params = Map(
"flags" -> List("${{matrix.scala}}", "${{matrix.java}}").mkString(",")
),
cond = Some("${{ matrix.scala != '" + Scala3 + "' }}")
)
)
ThisBuild / githubWorkflowAddedJobs ++= Seq(
WorkflowJob(
"scalafmt",
"Scalafmt",
githubWorkflowJobSetup.value.toList ::: List(
WorkflowStep.Sbt(
List("scalafmtCheckAll", "scalafmtSbtCheck"),
name = Some("Scalafmt tests")
)
),
scalas = crossScalaVersions.value.toList,
javas = List(JavaSpec.temurin("8"))
),
WorkflowJob(
"mima",
"Mima",
githubWorkflowJobSetup.value.toList :::
List(
WorkflowStep.Sbt(
List("mimaReportBinaryIssuesJVM"),
name = Some("Mima Check Java")
),
WorkflowStep.Sbt(
List("mimaReportBinaryIssuesJS"),
name = Some("Mima Check NodeJS")
)
),
scalas = crossScalaVersions.value.toList,
javas = List(JavaSpec.temurin("8")),
matrixFailFast = Option(false)
)
)
val compilerOptions = Def.setting(
Seq(
"-deprecation",
"-encoding",
"UTF-8",
"-feature",
"-language:existentials",
"-language:higherKinds",
"-unchecked",
"-Xfuture",
"-Yno-predef"
) ++ {
if (scalaBinaryVersion.value == "3")
Nil
else
Seq(
"-Ywarn-numeric-widen",
"-Ywarn-dead-code",
"-Ywarn-unused-import"
)
}
)
val catsVersion = "2.7.0"
val jawnVersion = "1.3.2"
val shapelessVersion = "2.3.9"
val refinedVersion = "0.9.28"
val paradiseVersion = "2.1.1"
val scalaTestVersion = "3.2.9"
val scalaCheckVersion = "1.15.4"
val munitVersion = "0.7.29"
val disciplineVersion = "1.4.0"
val disciplineScalaTestVersion = "2.1.5"
val disciplineMunitVersion = "1.0.9"
val scalaJavaTimeVersion = "2.3.0"
/**
* Some terrible hacks to work around Cats's decision to have builds for
* different Scala versions depend on different versions of Discipline, etc.
*/
def priorTo2_13(scalaVersion: String): Boolean =
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, minor)) if minor < 13 => true
case _ => false
}
val previousCirceVersions = List("0.14.0", "0.14.1").some
val scalaFiddleCirceVersion = "0.9.1"
lazy val disableScala3 = Def.settings(
libraryDependencies := {
if (scalaBinaryVersion.value == "3") {
Nil
} else {
libraryDependencies.value
}
},
Seq(Compile, Test).map { x =>
(x / sources) := {
if (scalaBinaryVersion.value == "3") {
Nil
} else {
(x / sources).value
}
}
},
Test / test := {
if (scalaBinaryVersion.value == "3") {
()
} else {
(Test / test).value
}
},
mimaPreviousArtifacts := { if (scalaVersion.value.startsWith("3")) Set.empty else mimaPreviousArtifacts.value },
publish / skip := (scalaBinaryVersion.value == "3")
)
lazy val baseSettings = Seq(
scalacOptions ++= {
if (priorTo2_13(scalaVersion.value)) compilerOptions.value
else
compilerOptions.value.flatMap {
case "-Ywarn-unused-import" => Seq("-Ywarn-unused:imports")
case "-Xfuture" => Nil
case other => Seq(other)
}
},
Compile / console / scalacOptions ~= {
_.filterNot(Set("-Ywarn-unused-import", "-Ywarn-unused:imports", "-Yno-predef"))
},
Test / console / scalacOptions ~= {
_.filterNot(Set("-Ywarn-unused-import", "-Ywarn-unused:imports", "-Yno-predef"))
},
Test / scalacOptions ~= {
_.filterNot(Set("-Yno-predef"))
},
resolvers ++= Seq(
Resolver.sonatypeRepo("releases"),
Resolver.sonatypeRepo("snapshots")
),
coverageHighlighting := true,
Compile / scalastyleSources ++= (Compile / unmanagedSourceDirectories).value,
ivyConfigurations += CompileTime.hide,
Compile / unmanagedClasspath ++= update.value.select(configurationFilter(CompileTime.name)),
Test / unmanagedClasspath ++= update.value.select(configurationFilter(CompileTime.name)),
testFrameworks += new TestFramework("munit.Framework")
)
lazy val allSettings = baseSettings ++ publishSettings
lazy val jsProjectSettings = Seq(
Test / scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule))
)
val isScala3 = Def.setting {
CrossVersion.partialVersion(scalaVersion.value).exists(_._1 != 2)
}
def circeProject(path: String)(project: Project) = {
val docName = path.split("-").mkString(" ")
project.settings(
description := s"circe $docName",
moduleName := s"circe-$path",
name := s"Circe $docName",
allSettings
)
}
def circeModule(path: String, mima: Option[List[String]]): Project = {
val id = path.split("-").reduce(_ + _.capitalize)
Project(id, file(s"modules/$path"))
.configure(circeProject(path))
.settings(
mima.map(versions => mimaPreviousArtifacts := versions.map("io.circe" %%% moduleName.value % _).toSet).toSeq
)
}
def circeCrossModule(path: String, mima: Option[List[String]], crossType: CrossType = CrossType.Full) = {
val id = path.split("-").reduce(_ + _.capitalize)
CrossProject(id, file(s"modules/$path"))(JVMPlatform, JSPlatform)
.crossType(crossType)
.settings(allSettings)
.configure(circeProject(path))
.settings(
mima.map(versions => mimaPreviousArtifacts := versions.map("io.circe" %%% moduleName.value % _).toSet).toSeq
)
.jsSettings(
coverageEnabled := false,
jsProjectSettings,
scalacOptions += {
val tagOrHash =
if (!isSnapshot.value) s"v${version.value}"
else git.gitHeadCommit.value.getOrElse("master")
val local = (LocalRootProject / baseDirectory).value.toURI.toString
val remote = s"https://raw.githubusercontent.com/circe/circe/$tagOrHash/"
val opt = if (isScala3.value) "-scalajs-mapSourceURI" else "-P:scalajs:mapSourceURI"
s"$opt:$local->$remote"
}
)
}
/**
* We omit all Scala.js projects from Unidoc generation.
*/
def noDocProjects(sv: String): Seq[ProjectReference] =
(circeCrossModules.map(_._2) :+ tests :+ genericSimple :+ genericSimpleJS :+ benchmarkDotty).map(p =>
p: ProjectReference
)
lazy val docsMappingsAPIDir =
settingKey[String]("Name of subdirectory in site target directory for api docs")
lazy val docSettings = allSettings ++ Seq(
micrositeName := "circe",
micrositeDescription := "A JSON library for Scala powered by Cats",
micrositeAuthor := "Travis Brown",
micrositeHighlightTheme := "atom-one-light",
micrositeHomepage := "https://circe.github.io/circe/",
micrositeBaseUrl := "/circe",
micrositeDocumentationUrl := s"${docsMappingsAPIDir.value}/io/circe",
micrositeDocumentationLabelDescription := "API Documentation",
micrositeGithubOwner := "circe",
micrositeGithubRepo := "circe",
micrositeExtraMdFiles := Map(
file("CONTRIBUTING.md") -> ExtraMdFileConfig(
"contributing.md",
"docs",
Map("title" -> "Contributing", "position" -> "6")
)
),
micrositeExtraMdFilesOutput := resourceManaged.value / "main" / "jekyll",
micrositeTheme := "pattern",
micrositePalette := Map(
"brand-primary" -> "#5B5988",
"brand-secondary" -> "#292E53",
"brand-tertiary" -> "#222749",
"gray-dark" -> "#49494B",
"gray" -> "#7B7B7E",
"gray-light" -> "#E5E5E6",
"gray-lighter" -> "#F4F3F4",
"white-color" -> "#FFFFFF"
),
micrositeConfigYaml := ConfigYml(yamlInline = s"""
|scalafiddle:
| dependency: io.circe %%% circe-core % $scalaFiddleCirceVersion,io.circe %%% circe-generic % $scalaFiddleCirceVersion,io.circe %%% circe-parser % $scalaFiddleCirceVersion
""".stripMargin),
docsMappingsAPIDir := "api",
addMappingsToSiteDir(ScalaUnidoc / packageDoc / mappings, docsMappingsAPIDir),
ghpagesNoJekyll := true,
ScalaUnidoc / unidoc / scalacOptions ++= Seq(
"-groups",
"-implicits",
"-skip-packages",
"scalaz",
"-doc-source-url",
scmInfo.value.get.browseUrl + "/tree/master€{FILE_PATH}.scala",
"-sourcepath",
(LocalRootProject / baseDirectory).value.getAbsolutePath
),
/* Publish GitHub Pages { */
gitHubPagesOrgName := "circe",
gitHubPagesRepoName := "circe",
gitHubPagesSiteDir := baseDirectory.value / "target" / "site",
/* } Publish GitHub Pages */
scalacOptions ~= {
_.filterNot(Set("-Yno-predef"))
},
git.remoteRepo := "git@github.com:circe/circe.git",
ScalaUnidoc / unidoc / unidocProjectFilter :=
inAnyProject -- inProjects(noDocProjects(scalaVersion.value): _*),
makeSite / includeFilter := "*.html" | "*.css" | "*.png" | "*.jpg" | "*.gif" | "*.svg" | "*.js" | "*.swf" | "*.yml" | "*.md"
)
lazy val docs = project
.dependsOn(core, parser, shapes, testing)
.settings(
moduleName := "circe-docs",
name := "Circe docs",
mdocIn := file("docs/src/main/tut"),
libraryDependencies ++= Seq(
"io.circe" %% "circe-generic-extras" % "0.14.1",
"io.circe" %% "circe-optics" % "0.14.1"
)
)
.settings(docSettings)
.settings(noPublishSettings)
.disablePlugins(MimaPlugin)
.settings(macroSettings)
.enablePlugins(GhpagesPlugin)
.enablePlugins(MicrositesPlugin)
.enablePlugins(ScalaUnidocPlugin)
.enablePlugins(GitHubPagesPlugin)
lazy val circeCrossModules = Seq[(Project, Project)](
(numbersTesting, numbersTestingJS),
(numbers, numbersJS),
(core, coreJS),
(pointer, pointerJS),
(pointerLiteral, pointerLiteralJS),
(extras, extrasJS),
(generic, genericJS),
(shapes, shapesJS),
(literal, literalJS),
(refined, refinedJS),
(parser, parserJS),
(scodec, scodecJS),
(testing, testingJS),
(tests, testsJS),
(hygiene, hygieneJS),
(jawn, jawnJS)
)
lazy val circeJsModules = Seq[Project](scalajs, scalajsJavaTimeTest)
lazy val circeJvmModules = Seq[Project](benchmark, jawn)
lazy val circeDocsModules = Seq[Project](docs)
lazy val jvmProjects: Seq[Project] =
circeCrossModules.map(_._1) ++ circeJvmModules
lazy val jsProjects: Seq[Project] =
circeCrossModules.map(_._2) ++ circeJsModules
lazy val aggregatedProjects: Seq[ProjectReference] = (
circeCrossModules.flatMap(cp => Seq(cp._1, cp._2)) ++
circeJsModules ++ circeJvmModules
).map(p => p: ProjectReference)
lazy val macroSettings: Seq[Setting[_]] = Seq(
libraryDependencies ++= (if (isScala3.value) Nil
else
(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)
)
)
} else Nil
))),
scalacOptions ++= (
if (priorTo2_13(scalaVersion.value) || isScala3.value) Nil else Seq("-Ymacro-annotations")
)
)
lazy val circe = project
.in(file("."))
.settings(allSettings)
.settings(noPublishSettings)
.disablePlugins(MimaPlugin)
.settings(
console / initialCommands :=
"""
|import io.circe._
|import io.circe.generic.auto._
|import io.circe.literal._
|import io.circe.parser._
|import io.circe.syntax._
""".stripMargin
)
.aggregate(aggregatedProjects: _*)
lazy val circeJS = project
.settings(allSettings)
.settings(noPublishSettings)
.disablePlugins(MimaPlugin)
.aggregate(
jsProjects.map(p => p: ProjectReference): _*
)
lazy val circeJVM = project
.settings(allSettings)
.settings(noPublishSettings)
.disablePlugins(MimaPlugin)
.aggregate(
jvmProjects.map(p => p: ProjectReference): _*
)
lazy val numbersTestingBase =
circeCrossModule("numbers-testing", mima = previousCirceVersions, CrossType.Pure).settings(
scalacOptions ~= {
_.filterNot(Set("-Yno-predef"))
},
libraryDependencies += "org.scalacheck" %%% "scalacheck" % scalaCheckVersion,
coverageExcludedPackages := "io\\.circe\\.numbers\\.testing\\..*"
)
lazy val numbersTesting = numbersTestingBase.jvm
lazy val numbersTestingJS = numbersTestingBase.js
lazy val numbersBase = circeCrossModule("numbers", mima = previousCirceVersions)
.settings(
Test / scalacOptions += "-language:implicitConversions",
libraryDependencies +=
"org.typelevel" %%% "discipline-munit" % disciplineMunitVersion % Test
)
.dependsOn(numbersTestingBase % Test)
lazy val numbers = numbersBase.jvm
lazy val numbersJS = numbersBase.js
lazy val coreBase = circeCrossModule("core", mima = previousCirceVersions)
.settings(
libraryDependencies += "org.typelevel" %%% "cats-core" % catsVersion,
Compile / sourceGenerators += (Compile / sourceManaged).map(Boilerplate.gen).taskValue,
Compile / unmanagedSourceDirectories ++= {
def extraDirs(suffix: String) =
CrossType.Full.sharedSrcDir(baseDirectory.value, "main").toList.map(f => file(f.getPath + suffix))
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, y)) => extraDirs("-2") ++ (if (y >= 13) extraDirs("-2.13+") else Nil)
case Some((3, _)) => extraDirs("-3") ++ extraDirs("-2.13+")
case _ => Nil
}
}
)
.dependsOn(numbersBase)
lazy val core = coreBase.jvm
lazy val coreJS = coreBase.js
lazy val genericBase = circeCrossModule("generic", mima = previousCirceVersions)
.settings(macroSettings)
.settings(
libraryDependencies ++= (if (isScala3.value) Nil else Seq("com.chuusai" %%% "shapeless" % shapelessVersion)),
Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.AllLibraryJars,
Compile / unmanagedSourceDirectories ++= {
def extraDirs(suffix: String) =
CrossType.Full.sharedSrcDir(baseDirectory.value, "main").toList.map(f => file(f.getPath + suffix))
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, y)) => extraDirs("-2") ++ (if (y >= 13) extraDirs("-2.13+") else Nil)
case Some((3, _)) => extraDirs("-3") ++ extraDirs("-2.13+")
case _ => Nil
}
},
Test / unmanagedSourceDirectories ++= {
def extraDirs(suffix: String) =
CrossType.Full.sharedSrcDir(baseDirectory.value, "test").toList.map(f => file(f.getPath + suffix))
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, y)) => extraDirs("-2") ++ (if (y >= 13) extraDirs("-2.13+") else Nil)
case Some((3, _)) => extraDirs("-3") ++ extraDirs("-2.13+")
case _ => Nil
}
}
)
.jsSettings(
libraryDependencies ++= Seq(
"org.typelevel" %% "jawn-parser" % jawnVersion % Test,
"io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion % Test
)
)
.dependsOn(coreBase, testsBase % Test)
lazy val generic = genericBase.jvm
lazy val genericJS = genericBase.js
lazy val genericSimpleBase = circeCrossModule("generic-simple", mima = previousCirceVersions, CrossType.Pure)
.settings(macroSettings)
.settings(
crossScalaVersions := Seq("2.13.8"),
libraryDependencies += "com.chuusai" %%% "shapeless" % shapelessVersion,
Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.AllLibraryJars
)
.jsSettings(
libraryDependencies ++= Seq(
"org.typelevel" %% "jawn-parser" % jawnVersion % Test,
"io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion % Test
)
)
.dependsOn(coreBase, testsBase % Test, literalBase % Test)
lazy val genericSimple = genericSimpleBase.jvm
lazy val genericSimpleJS = genericSimpleBase.js
lazy val shapesBase = circeCrossModule("shapes", mima = previousCirceVersions, CrossType.Pure)
.settings(macroSettings)
.settings(
disableScala3,
libraryDependencies += ("com.chuusai" %%% "shapeless" % shapelessVersion).cross(CrossVersion.for3Use2_13),
Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.AllLibraryJars
)
.jsSettings(
libraryDependencies ++= Seq(
"org.typelevel" %% "jawn-parser" % jawnVersion % Test,
"io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion % Test
)
)
.dependsOn(coreBase, testsBase % Test, literalBase % Test)
lazy val shapes = shapesBase.jvm
lazy val shapesJS = shapesBase.js
lazy val literalBase = circeCrossModule("literal", mima = previousCirceVersions, CrossType.Pure)
.settings(macroSettings)
.settings(
libraryDependencies ++= Seq(
"org.scalacheck" %%% "scalacheck" % scalaCheckVersion % Test,
"org.scalameta" %%% "munit" % munitVersion % Test,
"org.scalameta" %%% "munit-scalacheck" % munitVersion % Test
) ++ (if (isScala3.value) Seq("org.typelevel" %%% "jawn-parser" % jawnVersion % Provided)
else Seq("com.chuusai" %%% "shapeless" % shapelessVersion)),
mimaPreviousArtifacts := { if (scalaVersion.value.startsWith("3")) Set.empty else mimaPreviousArtifacts.value }
)
.jsSettings(
libraryDependencies ++= Seq(
"io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion % Test,
"org.typelevel" %%% "jawn-parser" % jawnVersion % Provided
)
)
.dependsOn(coreBase, parserBase % Test, testingBase % Test)
lazy val literal = literalBase.jvm
lazy val literalJS = literalBase.js
lazy val refinedBase = circeCrossModule("refined", mima = previousCirceVersions)
.settings(
disableScala3,
libraryDependencies ++= Seq(
"eu.timepit" %%% "refined" % refinedVersion,
"eu.timepit" %%% "refined-scalacheck" % refinedVersion % Test
),
Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.AllLibraryJars
)
.jsSettings(
libraryDependencies += "io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion % Test
)
.dependsOn(coreBase, testsBase % Test)
lazy val refined = refinedBase.jvm
lazy val refinedJS = refinedBase.js
lazy val parserBase = circeCrossModule("parser", mima = previousCirceVersions)
.jvmConfigure(_.dependsOn(jawn))
.jsConfigure(_.dependsOn(scalajs))
.dependsOn(coreBase)
lazy val parser = parserBase.jvm
lazy val parserJS = parserBase.js
lazy val scalajs =
circeModule("scalajs", mima = previousCirceVersions)
.enablePlugins(ScalaJSPlugin)
.settings(jsProjectSettings)
.dependsOn(coreJS)
lazy val scalajsJavaTimeTest = circeModule("scalajs-java-time-test", mima = None)
.enablePlugins(ScalaJSPlugin)
.settings(noPublishSettings)
.disablePlugins(MimaPlugin)
.settings(
libraryDependencies ++= Seq(
"org.scalameta" %%% "munit" % munitVersion % Test
),
jsProjectSettings
)
.dependsOn(coreJS)
lazy val scodecBase = circeCrossModule("scodec", mima = previousCirceVersions)
.settings(
disableScala3,
libraryDependencies += "org.scodec" %%% "scodec-bits" % "1.1.30",
Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.AllLibraryJars
)
.jsSettings(
libraryDependencies += "io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion % Test
)
.dependsOn(coreBase, testsBase % Test)
lazy val scodec = scodecBase.jvm
lazy val scodecJS = scodecBase.js
lazy val testingBase = circeCrossModule("testing", mima = previousCirceVersions)
.settings(
scalacOptions ~= {
_.filterNot(Set("-Yno-predef"))
},
libraryDependencies ++= Seq(
"org.scalacheck" %%% "scalacheck" % scalaCheckVersion,
"org.typelevel" %%% "cats-laws" % catsVersion,
"org.typelevel" %%% "discipline-core" % disciplineVersion
)
)
.settings(
coverageExcludedPackages := "io\\.circe\\.testing\\..*"
)
.dependsOn(coreBase, numbersTestingBase)
lazy val testing = testingBase.jvm
lazy val testingJS = testingBase.js
lazy val testsBase = circeCrossModule("tests", mima = None)
.disablePlugins(MimaPlugin)
.settings(noPublishSettings)
.settings(
disableScala3,
scalacOptions ~= {
_.filterNot(Set("-Yno-predef"))
},
Test / scalacOptions += "-language:implicitConversions",
libraryDependencies ++= Seq(
("com.chuusai" %%% "shapeless" % shapelessVersion).cross(CrossVersion.for3Use2_13),
"org.typelevel" %%% "discipline-scalatest" % disciplineScalaTestVersion,
"org.typelevel" %%% "discipline-munit" % disciplineMunitVersion
),
Test / sourceGenerators += (Test / sourceManaged).map(Boilerplate.genTests).taskValue,
Compile / unmanagedSourceDirectories ++= {
def extraDirs(suffix: String) =
List("main").flatMap(CrossType.Full.sharedSrcDir(baseDirectory.value, _)).map(f => file(f.getPath + suffix))
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, y)) => extraDirs("-2") ++ (if (y >= 13) extraDirs("-2.13+") else Nil)
case Some((3, _)) => extraDirs("-3") ++ extraDirs("-2.13+")
case _ => Nil
}
},
Test / unmanagedSourceDirectories ++= {
def extraDirs(suffix: String) =
List("test").flatMap(CrossType.Full.sharedSrcDir(baseDirectory.value, _)).map(f => file(f.getPath + suffix))
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, y)) => extraDirs("-2") ++ (if (y >= 13) extraDirs("-2.13+") else Nil)
case Some((3, _)) => extraDirs("-3") ++ extraDirs("-2.13+")
case _ => Nil
}
}
)
.settings(
coverageExcludedPackages := "io\\.circe\\.tests\\..*"
)
.jvmSettings(
fork := true
)
.jsSettings(
libraryDependencies += "io.github.cquiroz" %%% "scala-java-time" % scalaJavaTimeVersion % Test
)
.dependsOn(coreBase, parserBase, testingBase)
lazy val tests = testsBase.jvm
lazy val testsJS = testsBase.js
lazy val hygieneBase = circeCrossModule("hygiene", mima = None)
.settings(noPublishSettings)
.disablePlugins(MimaPlugin)
.settings(
disableScala3,
scalacOptions ++= Seq("-Yno-imports", "-Yno-predef")
)
.dependsOn(coreBase, genericBase, literalBase)
lazy val hygiene = hygieneBase.jvm.dependsOn(jawn)
lazy val hygieneJS = hygieneBase.js
lazy val jawnBase = circeCrossModule("jawn", mima = previousCirceVersions, CrossType.Full)
.settings(
libraryDependencies ++= Seq(
"org.typelevel" %%% "jawn-parser" % jawnVersion,
"org.typelevel" %%% "discipline-munit" % disciplineMunitVersion % Test
)
)
.dependsOn(coreBase)
lazy val jawn = jawnBase.jvm
lazy val jawnJS = jawnBase.js.settings(
mimaPreviousArtifacts := Set.empty, // Unsupported until 0.15.0-M1
mimaFailOnNoPrevious := false
)
lazy val pointerBase =
circeCrossModule("pointer", mima = previousCirceVersions, CrossType.Pure)
.settings(
libraryDependencies ++= Seq(
"org.typelevel" %%% "discipline-munit" % disciplineMunitVersion % Test
)
)
.dependsOn(coreBase, parserBase % Test)
lazy val pointer = pointerBase.jvm
lazy val pointerJS = pointerBase.js
lazy val pointerLiteralBase = circeCrossModule("pointer-literal", mima = previousCirceVersions, CrossType.Pure)
.settings(macroSettings)
.settings(
libraryDependencies ++= Seq(
"org.scalameta" %%% "munit" % munitVersion % Test,
"org.scalameta" %%% "munit-scalacheck" % munitVersion % Test
),
mimaPreviousArtifacts := { if (scalaVersion.value.startsWith("3")) Set.empty else mimaPreviousArtifacts.value }
)
.dependsOn(coreBase, pointerBase)
lazy val pointerLiteral = pointerLiteralBase.jvm
lazy val pointerLiteralJS = pointerLiteralBase.js
lazy val extrasBase = circeCrossModule("extras", mima = previousCirceVersions)
.settings(disableScala3)
.settings(noPublishSettings)
.dependsOn(coreBase, testsBase % Test)
lazy val extras = extrasBase.jvm
lazy val extrasJS = extrasBase.js
lazy val benchmark = circeModule("benchmark", mima = None)
.settings(noPublishSettings)
.disablePlugins(MimaPlugin)
.settings(
scalacOptions ~= {
_.filterNot(Set("-Yno-predef"))
},
libraryDependencies ++= Seq(
"io.circe" %% "circe-optics" % "0.14.1",
"org.scalameta" %% "munit" % munitVersion % Test
),
disableScala3
)
.enablePlugins(JmhPlugin)
.dependsOn(core, generic, jawn, pointer)
lazy val benchmarkDotty = circeModule("benchmark-dotty", mima = None)
.settings(noPublishSettings)
.disablePlugins(MimaPlugin)
.settings(
scalacOptions ~= {
_.filterNot(Set("-Yno-predef"))
}
)
.enablePlugins(JmhPlugin)
.dependsOn(core, jawn)
lazy val publishSettings = Seq(
releaseCrossBuild := true,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
releaseVcsSign := true,
homepage := Some(url("https://github.com/circe/circe")),
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/api/")),
scmInfo := Some(
ScmInfo(
url("https://github.com/circe/circe"),
"scm:git:git@github.com:circe/circe.git"
)
),
developers := List(
Developer("travisbrown", "Travis Brown", "travisrobertbrown@gmail.com", url("https://twitter.com/travisbrown"))
),
pomPostProcess := { (node: XmlNode) =>
new RuleTransformer(
new RewriteRule {
private def isTestScope(elem: Elem): Boolean =
elem.label == "dependency" && elem.child.exists(child => child.label == "scope" && child.text == "test")
override def transform(node: XmlNode): XmlNodeSeq = node match {
case elem: Elem if isTestScope(elem) => Nil
case _ => node
}
}
).transform(node).head
},
Compile / doc / sources := {
val src = (Compile / doc / sources).value
if (isScala3.value) Nil else src
}
)
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
)
).toSeq
lazy val CompileTime = config("compile-time")
val formatCommands = ";scalafmtCheckAll;scalafmtSbtCheck"
addCommandAlias("buildJVM", "circeJVM/compile")
addCommandAlias("mimaReportBinaryIssuesJVM", "circeJVM/mimaReportBinaryIssues")
addCommandAlias(
"validateJVM",
";buildJVM;circeJVM/test" + formatCommands
)
addCommandAlias("buildJS", "circeJS/compile")
addCommandAlias("mimaReportBinaryIssuesJS", "circeJVM/mimaReportBinaryIssues")
addCommandAlias(
"validateJS",
";buildJS;circeJS/test" + formatCommands
)
addCommandAlias("validate", ";validateJVM;validateJS")