forked from typelevel/spire
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
444 lines (392 loc) · 14.3 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
import sbtbuildinfo.Plugin._
import sbtunidoc.{Plugin => UnidocPlugin}
import sbtunidoc.Plugin.UnidocKeys._
import pl.project13.scala.sbt.SbtJmh
import ReleaseTransformations._
// Projects
lazy val spire = project.in(file("."))
.settings(moduleName := "spire-root")
.settings(spireSettings)
.settings(unidocSettings)
.settings(noPublishSettings)
.aggregate(spireJVM, spireJS)
.dependsOn(spireJVM, spireJS)
lazy val spireJVM = project.in(file(".spireJVM"))
.settings(moduleName := "spire-aggregate")
.settings(spireSettings)
.settings(unidocSettings)
.settings(noPublishSettings)
.aggregate(macrosJVM, coreJVM, extrasJVM, examples, lawsJVM, testsJVM, benchmark)
.dependsOn(macrosJVM, coreJVM, extrasJVM, examples, lawsJVM, testsJVM, benchmark)
lazy val spireJS = project.in(file(".spireJS"))
.settings(moduleName := "spire-aggregate")
.settings(spireSettings)
.settings(unidocSettings)
.settings(noPublishSettings)
.aggregate(macrosJS, coreJS, extrasJS, lawsJS, testsJS)
.dependsOn(macrosJS, coreJS, extrasJS, lawsJS, testsJS)
.enablePlugins(ScalaJSPlugin)
lazy val macros = crossProject.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 core = crossProject
.settings(moduleName := "spire")
.settings(spireSettings:_*)
.settings(coreSettings:_*)
.settings(buildInfoSettings:_*)
.settings(crossVersionSharedSources:_*)
.jvmSettings(commonJvmSettings:_*)
.jsSettings(commonJsSettings:_*)
.dependsOn(macros)
lazy val coreJVM = core.jvm
lazy val coreJS = core.js
lazy val extras = crossProject.crossType(CrossType.Pure)
.settings(moduleName := "spire-extras")
.settings(spireSettings:_*)
.settings(extrasSettings:_*)
.settings(buildInfoSettings:_*)
.settings(crossVersionSharedSources:_*)
.jvmSettings(commonJvmSettings:_*)
.jsSettings(commonJsSettings:_*)
.dependsOn(core)
lazy val extrasJVM = extras.jvm
lazy val extrasJS = extras.js
lazy val examples = project
.settings(moduleName := "spire-examples")
.settings(spireSettings)
.settings(libraryDependencies ++= Seq(
"com.chuusai" %% "shapeless" % "2.3.2",
"org.apfloat" % "apfloat" % "1.8.2",
"org.jscience" % "jscience" % "4.3.1"
))
.settings(noPublishSettings)
.settings(commonJvmSettings)
.dependsOn(coreJVM, extrasJVM)
lazy val laws = crossProject.crossType(CrossType.Pure)
.settings(moduleName := "spire-laws")
.settings(spireSettings:_*)
.settings(libraryDependencies ++= Seq(
"org.typelevel" %%% "discipline" % "0.7.2",
"org.scalacheck" %%% "scalacheck" % "1.13.4"
))
.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.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, extras, laws)
lazy val testsJVM = tests.jvm
lazy val testsJS = tests.js
lazy val benchmark = project
.settings(moduleName := "spire-benchmark")
.settings(spireSettings)
.settings(benchmarkSettings)
.settings(noPublishSettings)
.settings(commonJvmSettings)
.dependsOn(coreJVM, extrasJVM)
lazy val benchmarkJmh: Project = project.in(file("benchmark-jmh"))
.settings(moduleName := "spire-benchmark-jmh")
.settings(spireSettings)
.settings(SbtJmh.jmhSettings)
.settings(noPublishSettings)
.settings(commonJvmSettings)
.dependsOn(coreJVM, extrasJVM, benchmark)
// 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.spire-math",
scalaVersion := "2.12.0",
crossScalaVersions := Seq("2.10.6", "2.11.8", "2.12.0")
)
lazy val commonSettings = Seq(
scalacOptions ++= commonScalacOptions.diff(Seq(
"-Xfatal-warnings",
"-language:existentials",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard"
)),
resolvers ++= Seq(
"bintray/non" at "http://dl.bintray.com/non/maven",
Resolver.sonatypeRepo("snapshots")
),
libraryDependencies += "org.typelevel" %%% "machinist" % "0.6.1"
) ++ 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",
testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oDF")
)
lazy val publishSettings = Seq(
homepage := Some(url("http://spire-math.org")),
licenses += ("MIT", url("http://opensource.org/licenses/MIT")),
pomExtra := (
<scm>
<url>git@github.com:non/spire.git</url>
<connection>scm:git:git@github.com:non/spire.git</connection>
</scm>
<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 := scalaBinaryVersion.value != "2.10",
coverageExcludedPackages := "spire\\.benchmark\\..*;spire\\.macros\\..*"
)
// Project's settings
lazy val benchmarkSettings = Seq(
// raise memory limits here if necessary
// TODO: this doesn't seem to be working with caliper at the moment :(
javaOptions in run += "-Xmx4G",
libraryDependencies ++= Seq(
// comparisons
"org.apfloat" % "apfloat" % "1.8.2",
"org.jscience" % "jscience" % "4.3.1",
"org.apache.commons" % "commons-math3" % "3.4.1",
// thyme
"ichi.bench" % "thyme" % "0.1.0" from "http://plastic-idolatry.com/jars/thyme-0.1.0.jar",
// caliper stuff
"com.google.guava" % "guava" % "18.0",
"com.google.code.java-allocation-instrumenter" % "java-allocation-instrumenter" % "2.1",
"com.google.code.caliper" % "caliper" % "1.0-SNAPSHOT" from "http://plastic-idolatry.com/jars/caliper-1.0-SNAPSHOT.jar",
"com.google.code.gson" % "gson" % "1.7.2"
),
// enable forking in run
fork in run := true
)
lazy val coreSettings = Seq(
sourceGenerators in Compile <+= buildInfo,
buildInfoKeys := Seq[BuildInfoKey](version, scalaVersion),
buildInfoPackage := "spire",
sourceGenerators in Compile <+= (genProductTypes in Compile),
genProductTypes <<= (sourceManaged in Compile, streams) map { (scalaSource, s) =>
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" % "1.13.4" % "test")
lazy val scalaTestSettings = Seq(
libraryDependencies += "org.scalatest" %%% "scalatest" % "3.0.1" % "test",
libraryDependencies += "com.chuusai" %% "shapeless" % "2.3.2" % "test"
)
lazy val spireSettings = buildSettings ++ commonSettings ++ publishSettings ++ scoverageSettings
lazy val unidocSettings = UnidocPlugin.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 += "org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided",
libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
// if scala 2.11+ is used, quasiquotes are merged into scala-reflect
case Some((2, scalaMajor)) if scalaMajor >= 11 => Seq()
// in Scala 2.10, quasiquotes are provided by macro paradise
case Some((2, 10)) =>
Seq(
compilerPlugin("org.scalamacros" % "paradise" % "2.0.1" cross CrossVersion.full),
"org.scalamacros" %% "quasiquotes" % "2.0.1" cross CrossVersion.binary
)
}
}
)
lazy val commonScalacOptions = Seq(
"-deprecation",
"-encoding", "UTF-8",
"-feature",
"-language:existentials",
"-language:higherKinds",
"-language:implicitConversions",
"-language:experimental.macros",
"-unchecked",
"-Xfatal-warnings",
"-Xlint",
"-Yno-adapted-args",
"-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,
ReleaseStep(action = Command.process("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))
)
// 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
)