forked from typelevel/spire
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
560 lines (497 loc) · 18.6 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
import microsites._
import ReleaseTransformations._
import sbtcrossproject.{CrossType, crossProject}
lazy val scalaVersions: Map[String, String] =
Map("2.11" -> "2.11.12", "2.12" -> "2.12.8")
lazy val scalaCheckVersion = "1.14.0"
lazy val scalaTestVersion = "3.0.6"
lazy val shapelessVersion = "2.3.3"
lazy val disciplineVersion = "0.11.0"
lazy val machinistVersion = "0.6.6"
lazy val algebraVersion = "1.0.1"
lazy val apfloatVersion = "1.8.3"
lazy val jscienceVersion = "4.3.1"
lazy val apacheCommonsMath3Version = "3.6.1"
// Projects
lazy val spire = project.in(file("."))
.settings(moduleName := "spire-root")
.settings(spireSettings)
.settings(unidocSettings)
.settings(noPublishSettings)
.enablePlugins(ScalaUnidocPlugin)
.aggregate(spireJVM, spireJS)
.dependsOn(spireJVM, spireJS)
lazy val spireJVM = project.in(file(".spireJVM"))
.settings(moduleName := "spire-aggregate")
.settings(spireSettings)
.settings(unidocSettings)
.settings(noPublishSettings)
.enablePlugins(ScalaUnidocPlugin)
.aggregate(macrosJVM, coreJVM, dataJVM, extrasJVM, examples, lawsJVM, legacyJVM, platformJVM, testsJVM, utilJVM, benchmark)
.dependsOn(macrosJVM, coreJVM, dataJVM, extrasJVM, examples, lawsJVM, legacyJVM, platformJVM, testsJVM, utilJVM, benchmark)
lazy val spireJS = project.in(file(".spireJS"))
.settings(moduleName := "spire-aggregate")
.settings(spireSettings)
.settings(unidocSettings)
.settings(noPublishSettings)
.enablePlugins(ScalaUnidocPlugin)
.aggregate(macrosJS, coreJS, dataJS, extrasJS, lawsJS, legacyJS, platformJS, testsJS, utilJS)
.dependsOn(macrosJS, coreJS, dataJS, extrasJS, lawsJS, legacyJS, platformJS, testsJS, utilJS)
.enablePlugins(ScalaJSPlugin)
lazy val platform = crossProject(JSPlatform, JVMPlatform)
.settings(moduleName := "spire-platform")
.settings(spireSettings:_*)
.settings(crossVersionSharedSources:_*)
.jvmSettings(commonJvmSettings:_*)
.jsSettings(commonJsSettings:_*)
.dependsOn(macros, util)
lazy val platformJVM = platform.jvm
lazy val platformJS = platform.js
lazy val macros = crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure)
.settings(moduleName := "spire-macros")
.settings(spireSettings:_*)
.settings(scalaCheckSettings:_*)
.settings(scalaTestSettings:_*)
.settings(crossVersionSharedSources:_*)
.jvmSettings(commonJvmSettings:_*)
.jsSettings(commonJsSettings:_*)
lazy val macrosJVM = macros.jvm
lazy val macrosJS = macros.js
lazy val data = crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure)
.settings(moduleName := "spire-data")
.settings(spireSettings:_*)
.settings(crossVersionSharedSources:_*)
.jvmSettings(commonJvmSettings:_*)
.jsSettings(commonJsSettings:_*)
lazy val dataJVM = data.jvm
lazy val dataJS = data.js
lazy val legacy = crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure)
.settings(moduleName := "spire-legacy")
.settings(spireSettings:_*)
.settings(crossVersionSharedSources:_*)
.jvmSettings(commonJvmSettings:_*)
.jsSettings(commonJsSettings:_*)
lazy val legacyJVM = legacy.jvm
lazy val legacyJS = legacy.js
lazy val util = crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure)
.settings(moduleName := "spire-util")
.settings(spireSettings:_*)
.settings(crossVersionSharedSources:_*)
.jvmSettings(commonJvmSettings:_*)
.jsSettings(commonJsSettings:_*)
.dependsOn(macros)
lazy val utilJVM = util.jvm
lazy val utilJS = util.js
lazy val core = crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure)
.settings(moduleName := "spire")
.settings(spireSettings:_*)
.settings(coreSettings:_*)
.settings(crossVersionSharedSources:_*)
.enablePlugins(BuildInfoPlugin)
.jvmSettings(commonJvmSettings:_*)
.jsSettings(commonJsSettings:_*)
.dependsOn(macros, platform, util)
lazy val coreJVM = core.jvm
lazy val coreJS = core.js
lazy val extras = crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure)
.settings(moduleName := "spire-extras")
.settings(spireSettings:_*)
.settings(extrasSettings:_*)
.settings(crossVersionSharedSources:_*)
.jvmSettings(commonJvmSettings:_*)
.jsSettings(commonJsSettings:_*)
.dependsOn(macros, platform, util, core, data)
lazy val extrasJVM = extras.jvm
lazy val extrasJS = extras.js
lazy val docs = project.in(file("docs"))
.enablePlugins(MicrositesPlugin)
.enablePlugins(ScalaUnidocPlugin)
.dependsOn(macrosJVM, coreJVM, extrasJVM)
.settings(moduleName := "spire-docs")
.settings(commonSettings:_*)
.settings(spireSettings:_*)
.settings(docSettings: _*)
.settings(noPublishSettings)
.enablePlugins(TutPlugin)
.settings(commonJvmSettings:_*)
lazy val examples = project
.settings(moduleName := "spire-examples")
.settings(spireSettings)
.settings(libraryDependencies ++= Seq(
"com.chuusai" %% "shapeless" % shapelessVersion,
"org.apfloat" % "apfloat" % apfloatVersion,
"org.jscience" % "jscience" % jscienceVersion
))
.settings(noPublishSettings)
.settings(commonJvmSettings)
.dependsOn(coreJVM, extrasJVM)
lazy val laws = crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure)
.settings(moduleName := "spire-laws")
.settings(spireSettings:_*)
.settings(libraryDependencies ++= Seq(
"org.typelevel" %%% "discipline" % disciplineVersion,
"org.scalacheck" %%% "scalacheck" % scalaCheckVersion
))
.jvmSettings(commonJvmSettings:_*)
.jsSettings(commonJsSettings:_*)
.dependsOn(core, extras)
lazy val lawsJVM = laws.jvm
lazy val lawsJS = laws.js
// Todo: As all tests in this list are commented out, no tests in testJS are run - but they are compiled.
// This list is TEMPORARY as tests are migrated to scala-js
lazy val jsTests = List(
/* "spire.PartialOrderSyntaxTest",
"spire.PartialSyntaxTest",
"spire.SyntaxTest",
//"spire.algebra.GCDTest",
"spire.algebra.NRootTest",
"spire.algebra.PartialOrderTest",
"spire.algebra.RingTest","*/
"spire.algebra.SignedTest"/*,
"spire.algebra.TrigTest",
"spire.laws.LawTests",
"spire.math.AlgebraicTest",
"spire.math.BinaryMergeCheck",
"spire.math.BitStringCheck",
"spire.math.BitStringTest",
"spire.math.ComplexCheck",
"spire.math.ComplexCheck2",
"spire.math.ComplexTest",
"spire.math.ContinuousIntervalTest",
"spire.math.CooperativeEqualityTest",
"spire.math.FastComplexCheck",
"spire.math.FixedPointCheck",
"spire.math.FpFilterTest",
"spire.math.IntervalCheck",
"spire.math.IntervalGeometricPartialOrderTest",
"spire.math.IntervalIteratorCheck",
"spire.math.IntervalReciprocalTest",
"spire.math.IntervalSubsetPartialOrderTest",
"spire.math.IntervalTest",
"spire.math.JetTest",
"spire.math.LinearSelectTest",
"spire.math.LiteralsTest",
"spire.math.MergingTest",
"spire.math.NaturalTest",
"spire.math.NumberPropertiesTest",
"spire.math.NumberTest",
"spire.math.NumericTest",
"spire.math.PackageCheck",
"spire.math.PackageTest",
"spire.math.PolynomialCheck",
"spire.math.PolynomialSamplingCheck",
"spire.math.PolynomialTest",
"spire.math.QuaternionCheck",
"spire.math.QuickSelectTest",
"spire.math.RationalCheck",
"spire.math.RationalTest",
"spire.math.RealCheck",
"spire.math.RingIntervalTest",
"spire.math.SafeLongTest",
"spire.math.SearchTest",
"spire.math.SortingTest",
"spire.math.TrileanCheck",
"spire.math.UByteTest",
"spire.math.UIntTest",
"spire.math.ULongTest",
"spire.math.UShortTest",
"spire.math.prime.FactorHeapCheck",
"spire.math.prime.FactorsCheck",
"spire.random.GaussianTest",
"spire.random.GeneratorTest",
"spire.random.SamplingTest",
"spire.random.ShufflingTest",
"spire.syntax.CforTest",
"spire.util.OptCheck",
"spire.util.PackCheck",
"test.scala.spire.math.TypeclassExistenceTest"
*/
)
lazy val tests = crossProject(JSPlatform, JVMPlatform).crossType(CrossType.Pure)
.settings(moduleName := "spire-tests")
.settings(spireSettings:_*)
.settings(scalaTestSettings:_*)
.settings(noPublishSettings:_*)
.jvmSettings(commonJvmSettings:_*)
.jsSettings(testOptions in Test := Seq(Tests.Filter(s => jsTests.contains(s))))
.jsSettings(commonJsSettings:_*)
.dependsOn(core, data, legacy, extras, laws)
lazy val testsJVM = tests.jvm
lazy val testsJS = tests.js
lazy val benchmark: Project = project.in(file("benchmark"))
.settings(moduleName := "spire-benchmark")
.settings(spireSettings)
.settings(noPublishSettings)
.settings(commonJvmSettings)
.settings(
libraryDependencies ++= Seq(
"org.apfloat" % "apfloat" % apfloatVersion,
"org.jscience" % "jscience" % jscienceVersion,
"org.apache.commons" % "commons-math3" % apacheCommonsMath3Version
)
)
.enablePlugins(JmhPlugin)
.dependsOn(coreJVM, extrasJVM)
// General settings
addCommandAlias("validateJVM", ";coreJVM/scalastyle;macrosJVM/test;coreJVM/test;extrasJVM/test;lawsJVM/test;testsJVM/test;examples/test;benchmark/test")
addCommandAlias("validateJS", ";macrosJS/test;coreJS/test;extrasJS/test;lawsJS/test;testsJS/test")
addCommandAlias("validate", ";validateJVM;validateJS")
lazy val buildSettings = Seq(
organization := "org.typelevel",
scalaVersion := scalaVersions("2.12"),
crossScalaVersions := Seq(scalaVersions("2.11"), scalaVersions("2.12"))
)
lazy val commonDeps = Seq(libraryDependencies ++= Seq(
"org.typelevel" %%% "machinist" % machinistVersion,
"org.typelevel" %%% "algebra" % algebraVersion))
lazy val commonSettings = Seq(
scalacOptions ++= commonScalacOptions.value.diff(Seq(
"-Xfatal-warnings",
"-language:existentials",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard"
)),
resolvers += Resolver.sonatypeRepo("snapshots")
) ++ scalaMacroDependencies ++ warnUnusedImport
lazy val commonJsSettings = Seq(
scalaJSStage in Global := FastOptStage,
parallelExecution in Test := false
)
lazy val commonJvmSettings = Seq(
// -optimize has no effect in scala-js other than slowing down the build
// scalacOptions += "-optimize", // disabling for now
scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, scalaMajor)) if scalaMajor <= 11 => Seq("-optimize")
case _ => Seq.empty
}),
testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oDF")
)
lazy val docsMappingsAPIDir = settingKey[String]("Name of subdirectory in site target directory for api docs")
lazy val docSettings = Seq(
scalacOptions in Tut := (scalacOptions in Tut).value.filterNot(Set("-Ywarn-unused-imports", "-Xlint").contains),
micrositeName := "Spire",
micrositeDescription := "Powerful new number types and numeric abstractions for Scala",
micrositeAuthor := "Spire contributors",
micrositeHighlightTheme := "atom-one-light",
micrositeHomepage := "https://typelevel.org/spire",
micrositeBaseUrl := "spire",
micrositeDocumentationUrl := "/spire/api/spire/index.html",
micrositeDocumentationLabelDescription := "API Documentation",
micrositeExtraMdFiles := Map(
file("AUTHORS.md") -> ExtraMdFileConfig(
"authors.md",
"home",
Map("title" -> "Authors", "section" -> "Home", "position" -> "5")
),
file("CHANGES.md") -> ExtraMdFileConfig(
"changes.md",
"home",
Map("title" -> "Changes", "section" -> "Home", "position" -> "2")
),
file("CONTRIBUTING.md") -> ExtraMdFileConfig(
"contributing.md",
"home",
Map("title" -> "Contributing", "section" -> "Home", "position" -> "3")
),
file("DESIGN.md") -> ExtraMdFileConfig(
"design.md",
"home",
Map("title" -> "Design notes", "section" -> "Home", "position" -> "4")
),
file("FRIENDS.md") -> ExtraMdFileConfig(
"friends.md",
"home",
Map("title" -> "Friends of Spire", "section" -> "Home", "position" -> "6")
)
),
micrositeGithubOwner := "typelevel",
micrositeGithubRepo := "spire",
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(
yamlCustomProperties = Map(
"spireVersion" -> version.value,
"scalaVersion" -> scalaVersion.value
)
),
autoAPIMappings := true,
unidocProjectFilter in (ScalaUnidoc, unidoc) :=
inProjects(platformJVM, macrosJVM, dataJVM, legacyJVM, utilJVM, coreJVM, extrasJVM, lawsJVM),
docsMappingsAPIDir := "api",
addMappingsToSiteDir(mappings in (ScalaUnidoc, packageDoc), docsMappingsAPIDir),
ghpagesNoJekyll := false,
fork := true,
javaOptions += "-Xmx4G", // to have enough memory in forks
// fork in tut := true,
// fork in (ScalaUnidoc, unidoc) := true,
scalacOptions in (ScalaUnidoc, unidoc) ++= Seq(
"-groups",
"-doc-source-url", scmInfo.value.get.browseUrl + "/tree/master€{FILE_PATH}.scala",
"-sourcepath", baseDirectory.in(LocalRootProject).value.getAbsolutePath,
"-diagrams"
),
scalacOptions in Tut ~= (_.filterNot(Set("-Ywarn-unused-import", "-Ywarn-dead-code"))),
git.remoteRepo := "[email protected]:typelevel/spire.git",
includeFilter in makeSite := "*.html" | "*.css" | "*.png" | "*.jpg" | "*.gif" | "*.js" | "*.swf" | "*.yml" | "*.md" | "*.svg",
includeFilter in Jekyll := (includeFilter in makeSite).value
)
lazy val publishSettings = Seq(
homepage := Some(url("https://typelevel.org/spire/")),
licenses += ("MIT", url("http://opensource.org/licenses/MIT")),
pomExtra := (
<developers>
<developer>
<id>d_m</id>
<name>Erik Osheim</name>
<url>http://github.com/non/</url>
</developer>
<developer>
<id>tixxit</id>
<name>Tom Switzer</name>
<url>http://github.com/tixxit/</url>
</developer>
</developers>
)
) ++ credentialSettings ++ sharedPublishSettings ++ sharedReleaseProcess
lazy val scoverageSettings = Seq(
coverageMinimum := 40,
coverageFailOnMinimum := false,
coverageHighlighting := true,
coverageExcludedPackages := "spire\\.benchmark\\..*;spire\\.macros\\..*"
)
lazy val coreSettings = Seq(
buildInfoKeys := Seq[BuildInfoKey](version, scalaVersion),
buildInfoPackage := "spire",
sourceGenerators in Compile += (genProductTypes in Compile).taskValue,
genProductTypes := {
val scalaSource = (sourceManaged in Compile).value
val s = streams.value
s.log.info("Generating spire/std/tuples.scala")
val algebraSource = ProductTypes.algebraProductTypes
val algebraFile = (scalaSource / "spire" / "std" / "tuples.scala").asFile
IO.write(algebraFile, algebraSource)
Seq[File](algebraFile)
}
)
lazy val extrasSettings = Seq(
// sourceGenerators in Compile <+= buildInfo,
// buildInfoKeys := Seq[BuildInfoKey](version, scalaVersion),
// buildInfoPackage := "spire.extras"
)
lazy val genProductTypes = TaskKey[Seq[File]]("gen-product-types", "Generates several type classes for Tuple2-22.")
lazy val scalaCheckSettings = Seq(libraryDependencies += "org.scalacheck" %%% "scalacheck" % scalaCheckVersion % "test")
lazy val scalaTestSettings = Seq(
libraryDependencies += "org.scalatest" %%% "scalatest" % scalaTestVersion % "test",
libraryDependencies += "com.chuusai" %% "shapeless" % shapelessVersion % "test"
)
lazy val spireSettings = buildSettings ++ commonSettings ++ commonDeps ++ publishSettings ++ scoverageSettings
lazy val unidocSettings = Seq(
unidocProjectFilter in (ScalaUnidoc, unidoc) := inAnyProject -- inProjects(examples, benchmark, testsJVM)
)
////////////////////////////////////////////////////////////////////////////////////////////////////
// Base Build Settings - Should not need to edit below this line.
// These settings could also come from another file or a plugin.
// The only issue if coming from a plugin is that the Macro lib versions
// are hard coded, so an overided facility would be required.
addCommandAlias("gitSnapshots", ";set version in ThisBuild := git.gitDescribedVersion.value.get + \"-SNAPSHOT\"")
lazy val noPublishSettings = Seq(
publish := (()),
publishLocal := (()),
publishArtifact := false
)
lazy val crossVersionSharedSources: Seq[Setting[_]] =
Seq(Compile, Test).map { sc =>
(unmanagedSourceDirectories in sc) ++= {
(unmanagedSourceDirectories in sc ).value.map {
dir:File =>
CrossVersion.partialVersion(scalaBinaryVersion.value) match {
case Some((major, minor)) =>
new File(s"${dir.getPath}_$major.$minor")
case None =>
sys.error("couldn't parse scalaBinaryVersion ${scalaBinaryVersion.value}")
}
}
}
}
lazy val scalaMacroDependencies: Seq[Setting[_]] = Seq(
libraryDependencies += scalaOrganization.value % "scala-reflect" % scalaVersion.value % "provided"
)
lazy val commonScalacOptions = Def.setting(
(CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v >= 13 =>
Seq()
case _ =>
Seq("-Yno-adapted-args")
}) ++ Seq(
"-deprecation",
"-encoding", "UTF-8",
"-feature",
"-language:existentials",
"-language:higherKinds",
"-language:implicitConversions",
"-language:experimental.macros",
"-unchecked",
"-Xfatal-warnings",
"-Xlint",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-Xfuture"
)
)
lazy val sharedPublishSettings = Seq(
releaseCrossBuild := true,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
publishMavenStyle := true,
publishArtifact in Test := false,
pomIncludeRepository := Function.const(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")
}
)
lazy val sharedReleaseProcess = Seq(
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
publishArtifacts,
setNextVersion,
commitNextVersion,
releaseStepCommand("sonatypeReleaseAll"),
pushChanges)
)
lazy val warnUnusedImport = Seq(
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 10)) =>
Seq()
case Some((2, n)) if n >= 11 =>
Seq("-Ywarn-unused-import")
}
},
scalacOptions in (Compile, console) ~= {_.filterNot("-Ywarn-unused-import" == _)},
scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value
)
// For Travis CI - see http://www.cakesolutions.net/teamblogs/publishing-artefacts-to-oss-sonatype-nexus-using-sbt-and-travis-ci
lazy val credentialSettings = Seq(
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
)