forked from lloydmeta/enumeratum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
952 lines (865 loc) · 29 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
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
import com.typesafe.sbt.SbtGit.{GitKeys => git}
import sbtbuildinfo.BuildInfoPlugin.autoImport._
import sbtcrossproject.CrossPlugin.autoImport.{CrossType, crossProject}
lazy val scala_2_11Version = "2.11.12"
lazy val scala_2_12Version = "2.12.17"
lazy val scala_2_13Version = "2.13.10"
lazy val scala_3Version = "3.2.1"
lazy val scalaVersionsAll =
Seq(scala_2_11Version, scala_2_12Version, scala_2_13Version, scala_3Version)
lazy val theScalaVersion = scala_3Version
lazy val scalaTestVersion = "3.2.9"
def thePlayJsonVersion(scalaVersion: String) =
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, scalaMajor)) if scalaMajor <= 11 => "2.7.3"
// TODO drop 2.11 as play-json 2.7.x supporting Scala.js 1.x is unlikely?
case Some(_) => "2.10.0-RC6"
case _ =>
throw new IllegalArgumentException(s"Unsupported Scala version $scalaVersion for play-json")
}
def scalaTestPlay(scalaVersion: String) = CrossVersion.partialVersion(scalaVersion) match {
case Some((2, scalaMajor)) if scalaMajor >= 12 =>
"org.scalatestplus.play" %% "scalatestplus-play" % "5.0.0" % Test
case Some((3, _)) =>
("org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" % Test)
.cross(CrossVersion.for3Use2_13)
.exclude("org.scalactic", "*")
.exclude("org.scalatest", "*")
.exclude("org.scala-lang.modules", "*")
.exclude("com.typesafe.play", "play-json_2.13")
case _ =>
throw new IllegalArgumentException(s"Unsupported Scala version $scalaVersion for play-test")
}
lazy val baseProjectRefs =
Seq(macrosJS, macrosJVM, coreJS, coreJVM, coreJVMTests).map(Project.projectToRef)
lazy val scala213ProjectRefs = Seq(
enumeratumJson4s,
enumeratumScalacheckJvm,
enumeratumScalacheckJs,
enumeratumPlayJsonJvm,
enumeratumPlayJsonJs,
enumeratumArgonautJs,
enumeratumArgonautJvm,
enumeratumSlick,
enumeratumPlay,
enumeratumCirceJvm,
enumeratumCirceJs,
enumeratumReactiveMongoBson,
enumeratumCatsJvm,
enumeratumCatsJs,
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 scala211ProjectRefs = Seq(
enumeratumJson4s,
enumeratumScalacheckJvm,
enumeratumScalacheckJs,
// enumeratumPlayJsonJvm,
// TODO drop 2.11 as play-json 2.7.x supporting Scala.js 1.x is unlikely?
// enumeratumPlayJsonJs, TODO re-enable once play-json supports Scala.js 1.0
// enumeratumPlay,
enumeratumArgonautJs,
enumeratumArgonautJvm,
enumeratumSlick,
enumeratumCirceJvm,
enumeratumReactiveMongoBson,
enumeratumCatsJvm,
enumeratumQuillJvm
// enumeratumQuillJs TODO re-enable once quill supports Scala.js 1.0
).map(Project.projectToRef)
lazy val scala_2_11 = Project(id = "scala_2_11", base = file("scala_2_11"))
.settings(
commonSettings ++ publishSettings,
name := "enumeratum-scala_2_11",
scalaVersion := scala_2_11Version, // not sure if this and below are needed
crossScalaVersions := Seq(scala_2_11Version),
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 ++ scala211ProjectRefs): _*)
lazy val integrationProjectRefs = Seq(
enumeratumPlay,
enumeratumPlayJsonJs,
enumeratumPlayJsonJvm,
enumeratumCirceJs,
enumeratumCirceJvm,
enumeratumReactiveMongoBson,
enumeratumArgonautJs,
enumeratumArgonautJvm,
enumeratumJson4s,
enumeratumScalacheckJs,
enumeratumScalacheckJvm,
// enumeratumQuillJs, TODO re-enable once quill supports Scala.js 1.0
enumeratumQuillJvm,
enumeratumDoobie,
enumeratumSlick,
enumeratumCatsJs,
enumeratumCatsJvm
).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)
lazy val macros = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.in(file("macros"))
.settings(testSettings)
.jsSettings(jsTestSettings)
.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.value
)
lazy val macrosJS = macros.js
lazy val macrosJVM = macros.jvm
lazy val useLocalVersion = true
// Aggregates core
lazy val coreAggregate = aggregateProject("core", coreJS, coreJVM)
lazy val core = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.in(file("enumeratum-core"))
.settings(testSettings)
.jsSettings(jsTestSettings)
.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.value
)
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 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.stable,
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.value,
publishArtifact := false,
publishLocal := {}
)
.dependsOn(coreJVM, macrosJVM)
lazy val scalaXmlTest = Def.setting[ModuleID] {
val ver: String = {
if (scalaBinaryVersion.value == "2.11") "1.3.0"
else "2.1.0"
}
"org.scala-lang.modules" %% "scala-xml" % ver % Test
}
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-RC7-SNAPSHOT" % Provided
},
libraryDependencies += scalaXmlTest.value,
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 := Versions.Core.head,
crossScalaVersions := Seq(
scala_2_12Version,
scala_2_13Version,
scala_3Version
),
libraryDependencies ++= Seq(
"com.typesafe.play" %%% "play-json" % thePlayJsonVersion(scalaVersion.value),
scalaXmlTest.value
),
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 := Versions.Core.head,
crossScalaVersions := scalaVersionsAll.filter(_ != scala_2_11Version),
libraryDependencies += {
val dep = ("com.typesafe.play" %% "play" % "2.8.0").exclude("org.scala-lang.modules", "*")
if (scalaBinaryVersion.value == "3") {
dep
.exclude("org.scala-lang.modules", "*")
.exclude("com.typesafe.play", "play-json_2.13")
.cross(CrossVersion.for3Use2_13)
} else {
dep
}
},
libraryDependencies += scalaTestPlay(scalaVersion.value),
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)
lazy val enumeratumCirce = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.in(file("enumeratum-circe"))
.settings(commonWithPublishSettings)
.settings(testSettings)
.jsSettings(jsTestSettings)
.settings(
name := "enumeratum-circe",
version := Versions.Core.head,
libraryDependencies ++= {
val ver: String = {
if (scalaBinaryVersion.value == "2.11") {
"0.11.1"
} else {
"0.14.1"
}
}
Seq(
"io.circe" %%% "circe-core" % ver,
scalaXmlTest.value
)
},
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)
)
lazy val enumeratumCirceJs = enumeratumCirce.js
.configure(configureWithLocal(coreJS, "compile->compile;test->test"))
lazy val enumeratumCirceJvm = enumeratumCirce.jvm
.configure(configureWithLocal(coreJVM, "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 = {
if (scalaBinaryVersion.value == "3") {
"6.3.8"
} else {
"6.2.5"
}
}
Seq(
"io.argonaut" %%% "argonaut" % ver,
scalaXmlTest.value
)
},
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.3"
Seq(
"org.json4s" %% "json4s-core" % ver,
"org.json4s" %% "json4s-native" % ver % Test,
scalaXmlTest.value
)
},
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)
lazy val enumeratumScalacheck = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.in(file("enumeratum-scalacheck"))
.settings(commonWithPublishSettings)
.settings(testSettings)
.jsSettings(jsTestSettings)
.settings(
name := "enumeratum-scalacheck",
version := Versions.Core.head,
crossScalaVersions := scalaVersionsAll,
libraryDependencies ++= {
val ver: String = {
if (scalaBinaryVersion.value == "2.11") {
"1.15.2"
} else {
"1.15.4"
}
}
Seq(
"org.scalacheck" %%% "scalacheck" % ver,
"org.scalatestplus" %%% "scalacheck-1-14" % "3.1.1.1" % Test
).map(
_.exclude("org.scala-lang.modules", "*")
.exclude("org.scalatest", "*")
.cross(CrossVersion.for3Use2_13)
)
},
libraryDependencies += scalaXmlTest.value,
libraryDependencies ++= {
if (useLocalVersion) {
Seq.empty
} else {
Seq(
"com.beachape" %%% "enumeratum" % Versions.Core.stable,
"com.beachape" %%% "enumeratum-test" % Versions.Core.stable % Test
)
}
}
)
lazy val enumeratumScalacheckJs = enumeratumScalacheck.js
.configure(configureWithLocal(coreJS, "compile->compile;test->test"))
lazy val enumeratumScalacheckJvm = enumeratumScalacheck.jvm
.configure(configureWithLocal(coreJVM, "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.value
)
},
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 "2.11" => "0.5.4"
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 := Versions.Macros.head,
libraryDependencies += {
val ver = {
if (scalaBinaryVersion.value == "2.11") {
"0.7.1"
} else {
"1.0.0-RC2"
}
}
"org.tpolecat" %% "doobie-core" % ver
},
libraryDependencies += scalaXmlTest.value,
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 := Versions.Core.head,
crossScalaVersions := scalaVersionsAll,
libraryDependencies ++= Seq(
("com.typesafe.slick" %% "slick" % "3.3.3").cross(CrossVersion.for3Use2_13),
"com.h2database" % "h2" % "1.4.197" % Test
),
libraryDependencies ++= {
if (useLocalVersion) {
Seq.empty
} else {
Seq("com.beachape" %% "enumeratum" % Versions.Core.stable)
}
}
)
.settings( // TODO: Remove once Slick is published for Dotty
disabledSettings
)
.configure(configureWithLocal(coreJVM))
// Cats
lazy val catsAggregate = aggregateProject("cats", enumeratumCatsJs, enumeratumCatsJvm)
lazy val enumeratumCats = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.in(file("enumeratum-cats"))
.settings(commonWithPublishSettings)
.settings(testSettings)
.jsSettings(jsTestSettings)
.settings(
name := "enumeratum-cats",
version := Versions.Core.head,
libraryDependencies += {
val ver = {
if (scalaBinaryVersion.value == "2.11") {
"2.0.0"
} else {
"2.6.1"
}
}
"org.typelevel" %%% "cats-core" % ver
},
libraryDependencies += scalaXmlTest.value,
libraryDependencies ++= {
if (useLocalVersion) {
Seq.empty
} else {
Seq("com.beachape" %%% "enumeratum" % Versions.Core.stable)
}
}
)
.jvmSettings(
crossScalaVersions := scalaVersionsAll
)
.jsSettings(
crossScalaVersions := scalaVersionsAll.filter(_ != scala_2_11Version)
)
lazy val enumeratumCatsJs = enumeratumCats.js.configure(configureWithLocal(coreJS))
lazy val enumeratumCatsJvm = enumeratumCats.jvm.configure(configureWithLocal(coreJVM))
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"
)
)
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")
},
pgpPassphrase := sys.env.get("PGP_PASSPHRASE").map(_.toCharArray),
publishMavenStyle := true,
Test / publishArtifact := false,
PgpKeys.pgpPassphrase := sys.env.get("PGP_PASSPHRASE").map(_.toCharArray),
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
)
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, scalaMajor)) if scalaMajor >= 13 =>
Seq(base / "compat" / "src" / cat / "scala-2.13")
.map(_.getCanonicalFile)
case Some((2, scalaMajor)) if scalaMajor >= 11 =>
Seq(base / "compat" / "src" / cat / "scala-2.11")
.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.11.x, 2.12.x, 2.13.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: _*)