-
Notifications
You must be signed in to change notification settings - Fork 150
/
build.sbt
892 lines (813 loc) · 27.8 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
885
886
887
888
889
890
891
892
import com.github.sbt.git.SbtGit.{GitKeys => git}
import sbtbuildinfo.BuildInfoPlugin.autoImport._
import sbtcrossproject.CrossPlugin.autoImport.{CrossType, crossProject}
lazy val scala_2_12Version = "2.12.18"
lazy val scala_2_13Version = "2.13.11"
lazy val scala_3Version = "3.3.0"
lazy val scalaVersionsAll = Seq(scala_2_12Version, scala_2_13Version, scala_3Version)
lazy val theScalaVersion = scala_2_12Version
lazy val scalaTestVersion = "3.2.19"
lazy val baseProjectRefs =
Seq(macrosJS, macrosJVM, macrosNative, coreJS, coreJVM, coreNative, coreJVMTests).map(
Project.projectToRef
)
lazy val scala213ProjectRefs = Seq(
enumeratumJson4s,
enumeratumScalacheckJvm,
enumeratumScalacheckJs,
enumeratumScalacheckNative,
enumeratumPlayJsonJvm,
enumeratumPlayJsonJs,
enumeratumArgonautJs,
enumeratumArgonautJvm,
enumeratumSlick,
enumeratumPlay,
enumeratumCirceJvm,
enumeratumCirceJs,
enumeratumCirceNative,
enumeratumReactiveMongoBson,
enumeratumCatsJvm,
enumeratumCatsJs,
enumeratumCatsNative,
enumeratumQuillJvm
// enumeratumQuillJs TODO re-enable once quill supports Scala.js 1.0
).map(Project.projectToRef)
lazy val scala_2_13 = Project(id = "scala_2_13", base = file("scala_2_13"))
.settings(
commonSettings ++ publishSettings,
name := "enumeratum-scala_2_13",
scalaVersion := scala_2_13Version, // not sure if this and below are needed
crossScalaVersions := Seq(scala_2_13Version),
crossVersion := CrossVersion.binary,
// Do not publish this project (it just serves as an aggregate)
publishArtifact := false,
publishLocal := {},
// doctestWithDependencies := false, // sbt-doctest is not yet compatible with this 2.13
publish / aggregate := false,
PgpKeys.publishSigned / aggregate := false
)
.aggregate((baseProjectRefs ++ scala213ProjectRefs): _*)
// Disable cats and circe js modules here, as they don't have versions compatible with Scala.js 1.0 on Scala 2.11
lazy val integrationProjectRefs = Seq(
enumeratumPlay,
enumeratumPlayJsonJs,
enumeratumPlayJsonJvm,
enumeratumCirceJs,
enumeratumCirceJvm,
enumeratumCirceNative,
enumeratumReactiveMongoBson,
enumeratumArgonautJs,
enumeratumArgonautJvm,
enumeratumJson4s,
enumeratumScalacheckJs,
enumeratumScalacheckJvm,
enumeratumScalacheckNative,
// enumeratumQuillJs, TODO re-enable once quill supports Scala.js 1.0
enumeratumQuillJvm,
enumeratumDoobie,
enumeratumSlick,
enumeratumCatsJs,
enumeratumCatsJvm,
enumeratumCatsNative
).map(Project.projectToRef)
lazy val root =
Project(id = "enumeratum-root", base = file("."))
.settings(commonWithPublishSettings)
.settings(
name := "enumeratum-root",
crossVersion := CrossVersion.binary,
crossScalaVersions := Nil,
git.gitRemoteRepo := "[email protected]:lloydmeta/enumeratum.git",
// Do not publish the root project (it just serves as an aggregate)
publishArtifact := false,
publishLocal := {},
publish / aggregate := false,
PgpKeys.publishSigned / aggregate := false
)
.aggregate(baseProjectRefs ++ integrationProjectRefs: _*)
lazy val macrosAggregate = aggregateProject("macros", macrosJS, macrosJVM, macrosNative)
lazy val macros = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("macros"))
.settings(testSettings)
.jsSettings(jsTestSettings)
.nativeSettings(nativeTestSettings)
.settings(commonWithPublishSettings)
.settings(withCompatUnmanagedSources(jsJvmCrossProject = true, includeTestSrcs = false))
.settings(
name := "enumeratum-macros",
version := Versions.Macros.head,
crossScalaVersions := scalaVersionsAll, // eventually move this to aggregateProject once more 2.13 libs are out
libraryDependencies += {
if (scalaBinaryVersion.value == "3") {
"org.scala-lang" %% "scala3-compiler" % scalaVersion.value % Provided
} else {
"org.scala-lang" % "scala-reflect" % scalaVersion.value
}
},
libraryDependencies += scalaXmlTest
)
lazy val macrosJS = macros.js
lazy val macrosJVM = macros.jvm
lazy val macrosNative = macros.native
lazy val useLocalVersion = sys.props.get("enumeratum.useLocalVersion").nonEmpty
// Aggregates core
lazy val coreAggregate = aggregateProject("core", coreJS, coreJVM, coreNative)
lazy val core = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("enumeratum-core"))
.settings(testSettings)
.jsSettings(jsTestSettings)
.nativeSettings(nativeTestSettings)
.settings(commonWithPublishSettings)
.settings(
name := "enumeratum",
version := Versions.Core.head,
crossScalaVersions := scalaVersionsAll,
libraryDependencies ++= {
if (useLocalVersion) {
Seq.empty
} else {
Seq("com.beachape" %% "enumeratum-macros" % Versions.Macros.stable)
}
},
libraryDependencies += scalaXmlTest
)
def configureWithLocal(
dep: (Project, Option[String]),
deps: List[(Project, Option[String])] = Nil
): Project => Project = {
if (useLocalVersion) { // used for testing macros
{ (prj: Project) =>
(dep :: deps).foldLeft(prj) {
case (p, (m, Some(x))) =>
p.dependsOn(m % x)
case (p, (m, None)) =>
p.dependsOn(m)
}
}
} else {
identity[Project]
}
}
def configureWithLocal(m: Project): Project => Project =
configureWithLocal(m -> Option.empty[String])
def configureWithLocal(m: Project, x: String): Project => Project =
configureWithLocal(m -> Some(x))
lazy val coreJS = core.js.configure(configureWithLocal(macrosJS))
lazy val coreJVM = core.jvm.configure(configureWithLocal(macrosJVM))
lazy val coreNative = core.native.configure(configureWithLocal(macrosNative))
lazy val coreJVMTests = Project(id = "coreJVMTests", base = file("enumeratum-core-jvm-tests"))
.enablePlugins(BuildInfoPlugin)
.settings(
buildInfoKeys := Seq[BuildInfoKey](
name,
version,
scalaVersion,
sbtVersion,
BuildInfoKey.action("macrosJVMClassesDir") {
(macrosJVM / Compile / classDirectory).value
}
),
buildInfoPackage := "enumeratum"
)
.settings(commonWithPublishSettings)
.settings(testSettings)
.settings(
name := "coreJVMTests",
version := Versions.Core.head,
crossScalaVersions := scalaVersionsAll,
Test / sourceGenerators += CoreJVMTest.testsGenerator,
libraryDependencies += {
if (scalaBinaryVersion.value == "3") {
"org.scala-lang" %% "scala3-compiler" % scalaVersion.value % Test
} else {
"org.scala-lang" % "scala-compiler" % scalaVersion.value % Test
}
},
libraryDependencies += scalaXmlTest,
publishArtifact := false,
publishLocal := {}
)
.dependsOn(coreJVM, macrosJVM)
lazy val scalaXmlTest: ModuleID = "org.scala-lang.modules" %% "scala-xml" % "2.1.0" % Test
lazy val testsAggregate =
aggregateProject("test", enumeratumTestJs, enumeratumTestJvm, enumeratumTestNative)
// Project models used in test for some subprojects
lazy val enumeratumTest = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("enumeratum-test"))
.settings(testSettings)
.jsSettings(jsTestSettings)
.nativeSettings(nativeTestSettings)
.settings(commonWithPublishSettings)
.settings(
name := "enumeratum-test",
version := Versions.Core.head,
crossScalaVersions := scalaVersionsAll,
libraryDependencies += {
"com.beachape" %%% "enumeratum" % Versions.Core.stable
}
)
lazy val enumeratumTestJs = enumeratumTest.js
lazy val enumeratumTestJvm = enumeratumTest.jvm
lazy val enumeratumTestNative = enumeratumTest.native
lazy val enumeratumReactiveMongoBson =
Project(id = "enumeratum-reactivemongo-bson", base = file("enumeratum-reactivemongo-bson"))
.settings(commonWithPublishSettings)
.settings(testSettings)
.settings(
version := Versions.Core.head,
crossScalaVersions := scalaVersionsAll,
libraryDependencies += {
"org.reactivemongo" %% "reactivemongo-bson-api" % "1.1.0-RC12" % Provided
},
libraryDependencies += scalaXmlTest,
libraryDependencies ++= {
if (useLocalVersion) {
Seq.empty
} else {
Seq(
"com.beachape" %% "enumeratum" % Versions.Core.stable,
"com.beachape" %% "enumeratum-test" % Versions.Core.stable % Test
)
}
}
)
.configure(configureWithLocal(coreJVM, "compile->compile;test->test"))
// Play-JSON
lazy val playJsonAggregate =
aggregateProject("play-json", enumeratumPlayJsonJs, enumeratumPlayJsonJvm)
lazy val enumeratumPlayJson = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.in(file("enumeratum-play-json"))
.settings(commonWithPublishSettings)
.settings(testSettings)
.jsSettings(jsTestSettings)
.settings(
name := "enumeratum-play-json",
version := "1.8.3-SNAPSHOT",
crossScalaVersions := scalaVersionsAll,
libraryDependencies ++= Seq(
"org.playframework" %%% "play-json" % "3.0.4",
scalaXmlTest
),
libraryDependencies ++= {
if (useLocalVersion) {
Seq.empty
} else {
Seq(
"com.beachape" %% "enumeratum" % Versions.Core.stable,
"com.beachape" %% "enumeratum-test" % Versions.Core.stable % Test
)
}
}
)
lazy val enumeratumPlayJsonJs = enumeratumPlayJson.js
.configure(configureWithLocal(coreJS, "compile->compile;test->test"))
lazy val enumeratumPlayJsonJvm = enumeratumPlayJson.jvm
.configure(configureWithLocal(coreJVM, "compile->compile;test->test"))
// Play
lazy val enumeratumPlay = Project(id = "enumeratum-play", base = file("enumeratum-play"))
.settings(commonWithPublishSettings)
.settings(testSettings)
.settings(
version := "1.8.3-SNAPSHOT",
// Play do not support 2.12 (default from common settings)
scalaVersion := scala_2_13Version,
crossScalaVersions := Seq(scala_2_13Version, scala_3Version),
libraryDependencies += ("org.playframework" %% "play" % "3.0.4")
.exclude("org.scala-lang.modules", "*"),
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "7.0.0" % Test,
libraryDependencies ++= {
if (useLocalVersion) {
Seq.empty
} else {
Seq(
"com.beachape" %% "enumeratum" % Versions.Core.stable,
"com.beachape" %% "enumeratum-test" % Versions.Core.stable % Test
)
}
},
scalacOptions ++= {
if (scalaBinaryVersion.value == "3") {
Seq("-Wconf:cat=deprecation&msg=.*right-biased.*:s")
} else {
Seq.empty
}
}
)
.settings(withCompatUnmanagedSources(jsJvmCrossProject = false, includeTestSrcs = true))
.configure(configureWithLocal(coreJVM, "compile->compile;test->test"))
.dependsOn(enumeratumPlayJsonJvm % "compile->compile;test->test")
// Circe
lazy val circeAggregate =
aggregateProject("circe", enumeratumCirceJs, enumeratumCirceJvm, enumeratumCirceNative)
lazy val enumeratumCirce = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("enumeratum-circe"))
.settings(commonWithPublishSettings)
.settings(testSettings)
.jsSettings(jsTestSettings)
.nativeSettings(nativeTestSettings)
.settings(
name := "enumeratum-circe",
version := Versions.Core.head,
libraryDependencies ++= Seq(
"io.circe" %%% "circe-core" % "0.14.10",
scalaXmlTest
),
libraryDependencies ++= {
if (useLocalVersion) {
Seq.empty
} else {
Seq("com.beachape" %%% "enumeratum" % Versions.Core.stable)
}
}
)
.jvmSettings(
crossScalaVersions := scalaVersionsAll
)
.jsSettings(
crossScalaVersions := Seq(scala_2_12Version, scala_2_13Version, scala_3Version)
)
.nativeSettings(
crossScalaVersions := Seq(scala_2_12Version, scala_2_13Version, scala_3Version)
)
lazy val enumeratumCirceJs = enumeratumCirce.js
.configure(configureWithLocal(coreJS, "compile->compile;test->test"))
lazy val enumeratumCirceJvm = enumeratumCirce.jvm
.configure(configureWithLocal(coreJVM, "compile->compile;test->test"))
lazy val enumeratumCirceNative = enumeratumCirce.native
.configure(configureWithLocal(coreNative, "compile->compile;test->test"))
// Argonaut
lazy val argonautAggregate =
aggregateProject("argonaut", enumeratumArgonautJs, enumeratumArgonautJvm)
lazy val enumeratumArgonaut = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.in(file("enumeratum-argonaut"))
.settings(commonWithPublishSettings)
.settings(testSettings)
.jsSettings(jsTestSettings)
.settings(
name := "enumeratum-argonaut",
version := Versions.Core.head,
crossScalaVersions := scalaVersionsAll,
libraryDependencies ++= {
val ver: String = "6.3.9"
Seq(
"io.argonaut" %%% "argonaut" % ver,
scalaXmlTest
)
},
libraryDependencies ++= {
if (useLocalVersion) {
Seq.empty
} else {
Seq("com.beachape" %%% "enumeratum" % Versions.Core.stable)
}
}
)
lazy val enumeratumArgonautJs = enumeratumArgonaut.js
.configure(configureWithLocal(coreJS))
lazy val enumeratumArgonautJvm = enumeratumArgonaut.jvm
.configure(configureWithLocal(coreJVM))
// JSON4S
lazy val enumeratumJson4s =
Project(id = "enumeratum-json4s", base = file("enumeratum-json4s"))
.settings(commonWithPublishSettings)
.settings(testSettings)
.settings(
version := Versions.Core.head,
crossScalaVersions := scalaVersionsAll,
libraryDependencies ++= {
val ver = "4.0.7"
Seq(
"org.json4s" %% "json4s-core" % ver,
"org.json4s" %% "json4s-native" % ver % Test,
scalaXmlTest
)
},
libraryDependencies ++= {
if (useLocalVersion) {
Seq.empty
} else {
Seq("com.beachape" %%% "enumeratum" % Versions.Core.stable)
}
}
)
.settings(
// TODO: Remove once JSON4S is fixed for Scala3;
// https://github.com/json4s/json4s/issues/1035
disabledSettings
)
.configure(configureWithLocal(coreJVM))
// ScalaCheck
lazy val scalacheckAggregate =
aggregateProject(
"scalacheck",
enumeratumScalacheckJs,
enumeratumScalacheckJvm,
enumeratumScalacheckNative
)
lazy val enumeratumScalacheck = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("enumeratum-scalacheck"))
.settings(commonWithPublishSettings)
.settings(testSettings)
.jsSettings(jsTestSettings)
.nativeSettings(nativeTestSettings)
.settings(
name := "enumeratum-scalacheck",
version := Versions.Core.head,
crossScalaVersions := scalaVersionsAll,
libraryDependencies ++= {
val (ver, mod, ver2) = ("1.18.0", "scalacheck-1-18", "3.2.19.0")
Seq(
"org.scalacheck" %%% "scalacheck" % ver,
"org.scalatestplus" %%% mod % ver2 % Test
).map(
_.exclude("org.scala-lang.modules", "*")
.exclude("org.scalatest", "*")
)
},
libraryDependencies += scalaXmlTest,
libraryDependencies ++= {
if (useLocalVersion) {
Seq.empty
} else {
Seq(
"com.beachape" %%% "enumeratum" % Versions.Core.stable,
"com.beachape" %%% "enumeratum-test" % Versions.Core.stable % Test
)
}
}
)
.jvmSettings(
crossScalaVersions := scalaVersionsAll
)
.nativeSettings(
crossScalaVersions := scalaVersionsAll
)
lazy val enumeratumScalacheckJs = enumeratumScalacheck.js
.configure(configureWithLocal(coreJS, "compile->compile;test->test"))
lazy val enumeratumScalacheckJvm = enumeratumScalacheck.jvm
.configure(configureWithLocal(coreJVM, "compile->compile;test->test"))
lazy val enumeratumScalacheckNative = enumeratumScalacheck.native
.configure(configureWithLocal(coreNative, "compile->compile;test->test"))
// Quill
lazy val quillAggregate =
aggregateProject(
"quill", /*enumeratumQuillJs,*/ enumeratumQuillJvm
) // TODO re-enable once quill supports Scala.js 1.0
.settings(crossScalaVersions := scalaVersionsAll)
lazy val enumeratumQuill =
crossProject(JVMPlatform /*, JSPlatform TODO re-enable once quill supports Scala.js 1.0 */ )
.crossType(CrossType.Pure)
.in(file("enumeratum-quill"))
.settings(commonWithPublishSettings)
.settings(testSettings)
// .jsSettings(jsTestSettings: _*) TODO re-enable once quill supports Scala.js 1.0 */,
.settings(
name := "enumeratum-quill",
version := Versions.Core.head,
crossScalaVersions := scalaVersionsAll,
libraryDependencies ++= {
val (core, ver) = {
if (scalaBinaryVersion.value == "3") {
"quill-engine" -> "4.4.0"
} else {
"quill-core" -> "4.1.0"
}
}
Seq(
"io.getquill" %%% core % ver,
"io.getquill" %%% "quill-sql" % ver % Test,
scalaXmlTest
)
},
libraryDependencies ++= {
if (useLocalVersion) {
Seq.empty
} else {
Seq("com.beachape" %%% "enumeratum" % Versions.Core.stable)
}
},
dependencyOverrides += {
val ver = scalaBinaryVersion.value match {
case "3" => "0.7.3"
case _ => "0.5.5"
}
"com.lihaoyi" %%% "pprint" % ver
}
)
// lazy val enumeratumQuillJs = enumeratumQuill.js // TODO re-enable once quill supports Scala.js 1.0
lazy val enumeratumQuillJvm = enumeratumQuill.jvm.configure(configureWithLocal(coreJVM))
lazy val enumeratumDoobie =
Project(id = "enumeratum-doobie", base = file("enumeratum-doobie"))
.settings(commonWithPublishSettings)
.settings(testSettings)
.settings(
crossScalaVersions := scalaVersionsAll,
version := "1.7.8-SNAPSHOT",
libraryDependencies += "org.tpolecat" %% "doobie-core" % "1.0.0-RC5",
libraryDependencies += scalaXmlTest,
libraryDependencies ++= {
if (useLocalVersion) {
Seq.empty
} else {
Seq("com.beachape" %% "enumeratum" % Versions.Core.stable)
}
}
)
.configure(configureWithLocal(coreJVM))
lazy val enumeratumSlick =
Project(id = "enumeratum-slick", base = file("enumeratum-slick"))
.settings(commonWithPublishSettings)
.settings(testSettings)
.settings(
version := "1.7.9-SNAPSHOT",
crossScalaVersions := scalaVersionsAll,
libraryDependencies ++= Seq(
("com.typesafe.slick" %% "slick" % "3.5.1"),
"com.h2database" % "h2" % "1.4.197" % Test
),
libraryDependencies += scalaXmlTest,
libraryDependencies ++= {
if (useLocalVersion) {
Seq.empty
} else {
Seq("com.beachape" %% "enumeratum" % Versions.Core.stable)
}
}
)
.configure(configureWithLocal(coreJVM))
// Cats
lazy val catsAggregate =
aggregateProject("cats", enumeratumCatsJs, enumeratumCatsJvm, enumeratumCatsNative)
lazy val enumeratumCats = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("enumeratum-cats"))
.settings(commonWithPublishSettings)
.settings(testSettings)
.jsSettings(jsTestSettings)
.nativeSettings(nativeTestSettings)
.settings(
name := "enumeratum-cats",
version := Versions.Core.head,
libraryDependencies += "org.typelevel" %%% "cats-core" % "2.12.0",
libraryDependencies += scalaXmlTest,
libraryDependencies ++= {
if (useLocalVersion) {
Seq.empty
} else {
Seq("com.beachape" %%% "enumeratum" % Versions.Core.stable)
}
}
)
.jvmSettings(
crossScalaVersions := scalaVersionsAll
)
.jsSettings(
crossScalaVersions := scalaVersionsAll
)
.nativeSettings(
crossScalaVersions := scalaVersionsAll
)
lazy val enumeratumCatsJs = enumeratumCats.js.configure(configureWithLocal(coreJS))
lazy val enumeratumCatsJvm = enumeratumCats.jvm.configure(configureWithLocal(coreJVM))
lazy val enumeratumCatsNative = enumeratumCats.native.configure(configureWithLocal(coreNative))
lazy val commonSettings = Seq(
organization := "com.beachape",
scalafmtOnCompile := true,
scalaVersion := theScalaVersion,
crossScalaVersions := scalaVersionsAll
) ++
compilerSettings ++
resolverSettings ++
ideSettings
lazy val commonSettingsWithTrimmings =
commonSettings ++
scoverageSettings
lazy val commonWithPublishSettings =
commonSettingsWithTrimmings ++
publishSettings
lazy val resolverSettings = Seq(
resolvers ++= Seq(
"Typesafe Releases" at "https://repo.typesafe.com/typesafe/releases/",
"Sonatype snapshots" at "https://oss.sonatype.org/content/repositories/snapshots",
"Sonatype releases" at "https://oss.sonatype.org/content/repositories/releases",
"Sonatype releases local" at "https://oss.sonatype.org/service/local/repositories/releases/content"
)
)
lazy val ideSettings = Seq(
// Faster "sbt gen-idea"
Global / transitiveClassifiers := Seq(Artifact.SourceClassifier)
)
lazy val compilerSettings = Seq(
ThisBuild / scalaJSStage := {
sys.props.get("sbt.scalajs.testOpt").orElse(sys.env.get("SCALAJS_TEST_OPT")) match {
case Some("full") => FullOptStage
case _ => FastOptStage
}
},
Compile / compile / scalacOptions ++= {
val minimal = Seq(
"-encoding",
"UTF-8", // yes, this is 2 args
"-feature",
"-language:existentials",
"-language:higherKinds",
"-language:implicitConversions",
"-unchecked",
"-Xfatal-warnings"
)
val base = {
if (scalaBinaryVersion.value == "3") {
minimal :+ "-deprecation"
} else {
minimal ++ Seq(
// "-Ywarn-adapted-args",
"-Xlog-free-terms",
"-Ywarn-dead-code", // N.B. doesn't work well with the ??? hole
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-Xfuture"
)
}
}
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, m)) if m >= 13 =>
base.filterNot(flag =>
flag == "-Xfatal-warnings" || flag == "-Xfuture"
) ++ // todo see how to disable deprecations in 2.13.x
Seq(
/*"-deprecation:false", */ "-Xlint:-unused,_"
) // unused-import breaks Circe Either shim
case Some((2, m)) if m >= 12 =>
base ++ Seq(
"-deprecation:false",
"-Xlint:-unused,_"
) // unused-import breaks Circe Either shim
case Some((2, 11)) => base ++ Seq("-deprecation:false", "-Xlint", "-Ywarn-unused-import")
case Some((2, _)) => base ++ Seq("-Xlint")
case _ => base
}
},
Test / scalacOptions ++= {
if (scalaBinaryVersion.value == "3") {
Seq("-Yretain-trees")
} else {
Seq.empty
}
}
)
lazy val scoverageSettings = Seq(
coverageExcludedPackages := """enumeratum\.EnumMacros;enumeratum\.ContextUtils;enumeratum\.ValueEnumMacros""",
coverageHighlighting := true
)
// Settings for publishing to Maven Central
lazy val publishSettings = Seq(
pomExtra :=
<url>https://github.com/lloydmeta/enumeratum</url>
<licenses>
<license>
<name>MIT</name>
<url>http://opensource.org/licenses/MIT</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>lloydmeta</id>
<name>Lloyd Chan</name>
<url>https://beachape.com</url>
</developer>
</developers>,
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (version.value.trim.endsWith("SNAPSHOT"))
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
},
publishMavenStyle := true,
Test / publishArtifact := false,
pomIncludeRepository := { _ =>
false
}
)
val testSettings = {
Seq(
libraryDependencies += {
val dep = "org.scalatest" %%% "scalatest" % scalaTestVersion % Test
if (scalaBinaryVersion.value == "3") {
dep.exclude("org.scala-lang.modules", "*")
} else {
dep
}
},
doctestGenTests := {
val originalValue = doctestGenTests.value
Seq.empty // TODO: re-enable originalValue
},
doctestTestFramework := DoctestTestFramework.ScalaTest
)
}
val jsTestSettings = Seq(
coverageEnabled := false, // Disable until Scala.js 1.0 support is there https://github.com/scoverage/scalac-scoverage-plugin/pull/287
doctestGenTests := Seq.empty
)
val nativeTestSettings = Seq(
coverageEnabled := false,
doctestGenTests := Seq.empty
)
lazy val disabledSettings = Seq(
doctestScalaTestVersion := Some(scalaTestVersion),
sourceDirectory := {
if (scalaBinaryVersion.value == "3") new java.io.File("/no/sources")
else sourceDirectory.value
},
publishArtifact := (scalaBinaryVersion.value != "3"),
publishLocal := {
if (publishArtifact.value) ({})
else publishLocal.value
}
)
lazy val benchmarking =
Project(id = "benchmarking", base = file("benchmarking"))
.settings(commonWithPublishSettings)
.settings(
name := "benchmarking",
crossVersion := CrossVersion.binary,
libraryDependencies += "org.slf4j" % "slf4j-simple" % "1.7.21",
// Do not publish
publishArtifact := false,
publishLocal := {}
)
.dependsOn((baseProjectRefs ++ integrationProjectRefs).map(ClasspathDependency(_, None)): _*)
.enablePlugins(JmhPlugin)
/** Helper function to add unmanaged source compat directories for different scala versions
*/
def withCompatUnmanagedSources(
jsJvmCrossProject: Boolean,
includeTestSrcs: Boolean
): Seq[Setting[_]] = {
def compatDirs(projectbase: File, scalaVersion: String, isMain: Boolean) = {
val base = if (jsJvmCrossProject) projectbase / ".." else projectbase
val cat = if (isMain) "main" else "test"
CrossVersion.partialVersion(scalaVersion) match {
case Some((3, _)) =>
Seq(base / "compat" / "src" / cat / "scala-3")
.map(_.getCanonicalFile)
case Some((2, 13)) =>
Seq(base / "compat" / "src" / cat / "scala-2.13")
.map(_.getCanonicalFile)
case Some((2, 12)) =>
Seq(base / "compat" / "src" / cat / "scala-2.12")
.map(_.getCanonicalFile)
case _ => Nil
}
}
val unmanagedMainDirsSetting = Seq(
Compile / unmanagedSourceDirectories ++= {
compatDirs(
projectbase = baseDirectory.value,
scalaVersion = scalaVersion.value,
isMain = true
)
}
)
if (includeTestSrcs) {
unmanagedMainDirsSetting ++ {
Test / unmanagedSourceDirectories ++= {
compatDirs(
projectbase = baseDirectory.value,
scalaVersion = scalaVersion.value,
isMain = false
)
}
}
} else {
unmanagedMainDirsSetting
}
}
/** Assumes that
*
* - a corresponding directory exists under ./aggregates.
* - publishing 2.12.x, 2.13.x, 3.x
*/
def aggregateProject(id: String, projects: ProjectReference*): Project =
Project(id = s"$id-aggregate", base = file(s"./aggregates/$id"))
.settings(commonWithPublishSettings: _*)
.settings(
crossScalaVersions := Nil,
crossVersion := CrossVersion.binary,
// Do not publish the aggregate project (it just serves as an aggregate)
libraryDependencies += {
"org.scalatest" %% "scalatest" % scalaTestVersion % Test
},
publishArtifact := false,
publishLocal := {}
)
.aggregate(projects: _*)