forked from typelevel/spire
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
290 lines (246 loc) · 8.34 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
import sbtunidoc.{Plugin => UnidocPlugin}
import sbtunidoc.Plugin.UnidocKeys._
import com.typesafe.sbt.pgp.PgpKeys._
import pl.project13.scala.sbt.SbtJmh
import sbtrelease._
import sbtrelease.ReleasePlugin._
import sbtrelease.ReleasePlugin.ReleaseKeys._
import sbtrelease.ReleaseStateTransformations._
import sbtrelease.Utilities._
import sbtbuildinfo.Plugin._
// Projects
lazy val spire = project.in(file("."))
.settings(moduleName := "spire-aggregate")
.settings(spireSettings)
.settings(unidocSettings)
.settings(noPublishSettings)
.aggregate(macros, core, examples, scalacheckBinding, tests, benchmark)
.dependsOn(macros, core, examples, scalacheckBinding, tests, benchmark)
lazy val macros = project
.settings(moduleName := "spire-macros")
.settings(spireSettings)
.settings(macroSettings)
lazy val core = project
.settings(moduleName := "spire")
.settings(spireSettings)
.settings(coreSettings)
.dependsOn(macros)
lazy val examples = project
.settings(moduleName := "spire-examples")
.settings(spireSettings)
.settings(examplesSettings)
.settings(noPublishSettings)
.dependsOn(core)
lazy val scalacheckBinding = project.in(file("scalacheck-binding"))
.settings(moduleName := "spire-scalacheck-binding")
.settings(spireSettings)
.settings(scalacheckSettings)
.dependsOn(core)
lazy val tests = project
.settings(moduleName := "spire-tests")
.settings(spireSettings)
.settings(testsSettings)
.settings(noPublishSettings)
.dependsOn(core, scalacheckBinding)
lazy val benchmark = project
.settings(moduleName := "spire-benchmark")
.settings(spireSettings)
.settings(benchmarkSettings)
.settings(noPublishSettings)
.dependsOn(core)
lazy val benchmarkJmh: Project = project.in(file("benchmark-jmh"))
.settings(moduleName := "spire-benchmark-jmh")
.settings(spireSettings)
.settings(SbtJmh.jmhSettings)
.settings(noPublishSettings)
.dependsOn(core, benchmark)
// General settings
lazy val buildSettings = Seq(
organization := "org.spire-math",
scalaVersion := "2.11.6",
// https://github.com/non/spire/pull/413#issuecomment-89896773
crossScalaVersions := Seq("2.10.4", "2.11.6")
)
lazy val commonSettings = Seq(
scalacOptions ++= Seq(
"-Yinline-warnings",
"-deprecation",
"-encoding", "UTF-8", // yes, this is 2 args
"-feature",
"-unchecked",
//"-Xfatal-warnings", // inliner warnings mean we leave this off
"-Xlint",
"-Xfuture",
"-Yno-adapted-args",
"-optimize",
"-language:experimental.macros",
"-language:higherKinds",
"-language:implicitConversions"
),
resolvers ++= Seq(
"bintray/non" at "http://dl.bintray.com/non/maven",
Resolver.sonatypeRepo("releases"),
Resolver.sonatypeRepo("snapshots")
),
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.typelevel" %% "machinist" % "0.3.0" // TODO: 0.3.1 causes compilation errors
) ++ {
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"
)
}
},
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))
)
lazy val publishSettings = Seq(
homepage := Some(url("http://spire-math.org")),
licenses := Seq("BSD-style" -> url("http://opensource.org/licenses/MIT")),
publishMavenStyle := true,
publishArtifact in Test := false,
pomIncludeRepository := Function.const(false),
publishTo <<= (version).apply { v =>
val nexus = "https://oss.sonatype.org/"
if (v.trim.endsWith("SNAPSHOT"))
Some("Snapshots" at nexus + "content/repositories/snapshots")
else
Some("Releases" at nexus + "service/local/staging/deploy/maven2")
},
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>
),
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
publishSignedArtifacts,
setNextVersion,
commitNextVersion,
pushChanges
)
)
lazy val noPublishSettings = Seq(
publish := (),
publishLocal := (),
publishArtifact := false
)
// Release step
lazy val publishSignedArtifacts = ReleaseStep(
action = st => {
val extracted = st.extract
val ref = extracted.get(thisProjectRef)
extracted.runAggregated(publishSigned in Global in ref, st)
},
check = st => {
// getPublishTo fails if no publish repository is set up.
val ex = st.extract
val ref = ex.get(thisProjectRef)
Classpaths.getPublishTo(ex.get(publishTo in Global in ref))
st
},
enableCrossBuild = true
)
// Dependencies
lazy val scalaTest = "org.scalatest" %% "scalatest" % "2.2.4"
lazy val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.12.2"
// Project's settings
lazy val spireSettings = buildSettings ++ commonSettings ++ publishSettings ++ releaseSettings
lazy val unidocSettings = UnidocPlugin.unidocSettings ++ Seq(
unidocProjectFilter in (ScalaUnidoc, unidoc) := inAnyProject -- inProjects(examples, benchmark, tests)
)
lazy val macroSettings = Seq(
libraryDependencies ++= Seq(scalaTest % "test", scalaCheck % "test"),
unmanagedSourceDirectories in Compile += (sourceDirectory in Compile).value / s"scala_${scalaBinaryVersion.value}"
)
lazy val genProductTypes = TaskKey[Seq[File]]("gen-product-types", "Generates several type classes for Tuple2-22.")
lazy val coreSettings = Seq(
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)
},
libraryDependencies ++= Seq(
scalaCheck % "test",
scalaTest % "test"
),
unmanagedSourceDirectories in Compile += (sourceDirectory in Compile).value / s"scala_${scalaBinaryVersion.value}"
) ++ buildInfoSettings ++ Seq(
sourceGenerators in Compile <+= buildInfo,
buildInfoKeys := Seq[BuildInfoKey](version, scalaVersion),
buildInfoPackage := "spire"
)
lazy val examplesSettings = Seq(
libraryDependencies ++= Seq(
"com.chuusai" %% "shapeless" % "1.2.4",
"org.apfloat" % "apfloat" % "1.8.2",
"org.jscience" % "jscience" % "4.3.1"
)
)
lazy val scalacheckSettings = Seq(
libraryDependencies ++= Seq(
"org.typelevel" %% "discipline" % "0.2.1",
scalaCheck
)
)
lazy val testsSettings = Seq(
libraryDependencies ++= Seq(
scalaTest % "test"
)
)
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.6.3",
"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
)