-
Notifications
You must be signed in to change notification settings - Fork 243
/
build.sbt
233 lines (195 loc) · 7.57 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
val header = """|**********************************************************************\
|* Project **
|* ______ ______ __ ______ ____ **
|* / ____/ / __ / / / / __ / / __/ (c) 2011-2021 **
|* / /__ / /_/ / / / / /_/ / / /_ **
|* /___ / / ____/ / / / __ / / __/ Erik Osheim, Tom Switzer **
|* ____/ / / / / / / / | | / /__ **
|* /_____/ /_/ /_/ /_/ |_| /____/ All rights reserved. **
|* **
|* Redistribution and use permitted under the MIT license. **
|* **
|\***********************************************************************
|""".stripMargin
import scala.language.existentials
lazy val scalaCheckVersion = "1.17.0"
lazy val munit = "1.0.0-M7"
lazy val munitDiscipline = "2.0.0-M3"
lazy val algebraVersion = "2.9.0"
lazy val apfloatVersion = "1.10.1"
lazy val jscienceVersion = "4.3.1"
lazy val apacheCommonsMath3Version = "3.6.1"
val Scala213 = "2.13.15"
val Scala3 = "3.2.2"
Global / onChangedBuildSource := ReloadOnSourceChanges
ThisBuild / tlBaseVersion := "0.18"
ThisBuild / scalaVersion := Scala213
ThisBuild / crossScalaVersions := Seq(Scala213, Scala3)
ThisBuild / githubWorkflowJavaVersions := Seq("8", "11", "17").map(JavaSpec.temurin(_))
ThisBuild / homepage := Some(url("https://typelevel.org/spire/"))
ThisBuild / licenses := Seq("MIT" -> url("https://opensource.org/licenses/MIT"))
ThisBuild / developers := List(
Developer(
"id_m",
"Erik Osheim",
"",
url("https://github.com/non/")
),
Developer(
"tixxit",
"Tom Switzer",
"",
url("https://github.com/tixxit/")
)
)
ThisBuild / tlFatalWarnings := false
// Projects
lazy val root = tlCrossRootProject
.aggregate(macros, core, extras, examples, laws, platform, tests, util, benchmark)
.settings(spireSettings)
.settings(unidocSettings)
.enablePlugins(ScalaUnidocPlugin)
lazy val platform = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.settings(moduleName := "spire-platform")
.settings(spireSettings: _*)
.jvmSettings(commonJvmSettings: _*)
.jsSettings(commonJsSettings: _*)
.dependsOn(macros, util)
lazy val macros = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.settings(moduleName := "spire-macros")
.settings(spireSettings: _*)
.settings(scalaCheckSettings: _*)
.settings(munitSettings: _*)
.jvmSettings(commonJvmSettings: _*)
.jsSettings(commonJsSettings: _*)
lazy val util = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.settings(moduleName := "spire-util")
.settings(spireSettings: _*)
.jvmSettings(commonJvmSettings: _*)
.jsSettings(commonJsSettings: _*)
.dependsOn(macros)
lazy val core = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.settings(moduleName := "spire")
.settings(spireSettings: _*)
.settings(coreSettings: _*)
.jvmSettings(commonJvmSettings: _*)
.jsSettings(commonJsSettings: _*)
.dependsOn(macros, platform, util)
lazy val extras = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.settings(moduleName := "spire-extras")
.settings(spireSettings: _*)
.settings(extrasSettings: _*)
.jvmSettings(commonJvmSettings: _*)
.jsSettings(commonJsSettings: _*)
.dependsOn(macros, platform, util, core)
lazy val docs = project
.in(file("site"))
.enablePlugins(TypelevelSitePlugin, ScalaUnidocPlugin)
.settings(laikaConfig ~= { _.withRawContent })
.dependsOn(macros.jvm, core.jvm, extras.jvm)
.settings(commonSettings: _*)
.settings(spireSettings: _*)
.settings(commonJvmSettings: _*)
lazy val examples = project
.settings(moduleName := "spire-examples")
.settings(spireSettings)
.settings(
libraryDependencies ++= Seq(
"org.apfloat" % "apfloat" % apfloatVersion,
"org.jscience" % "jscience" % jscienceVersion
)
)
.enablePlugins(NoPublishPlugin)
.settings(commonJvmSettings)
.dependsOn(core.jvm, extras.jvm)
lazy val laws = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Pure)
.settings(moduleName := "spire-laws")
.settings(spireSettings: _*)
.settings(
libraryDependencies ++= Seq(
"org.typelevel" %%% "algebra-laws" % algebraVersion,
"org.scalacheck" %%% "scalacheck" % scalaCheckVersion
)
)
.jvmSettings(commonJvmSettings: _*)
.jsSettings(commonJsSettings: _*)
.dependsOn(core, extras)
lazy val tests = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.crossType(CrossType.Full)
.settings(moduleName := "spire-tests")
.settings(spireSettings: _*)
.settings(munitSettings: _*)
.enablePlugins(NoPublishPlugin)
.jvmSettings(commonJvmSettings: _*)
.jsSettings(commonJsSettings: _*)
.dependsOn(core, extras, laws)
lazy val benchmark: Project = project
.in(file("benchmark"))
.settings(moduleName := "spire-benchmark")
.settings(spireSettings)
.enablePlugins(NoPublishPlugin)
.settings(commonJvmSettings)
.settings(
libraryDependencies ++= Seq(
"org.apfloat" % "apfloat" % apfloatVersion,
"org.jscience" % "jscience" % jscienceVersion,
"org.apache.commons" % "commons-math3" % apacheCommonsMath3Version
)
)
.enablePlugins(JmhPlugin)
.dependsOn(core.jvm, extras.jvm)
lazy val buildSettings = Seq(
scalacOptions := {
if (tlIsScala3.value)
scalacOptions.value.filterNot(Set("-source:3.0-migration"))
else
scalacOptions.value
}
)
lazy val commonDeps = Seq(
libraryDependencies ++= Seq(
"org.typelevel" %%% "algebra" % algebraVersion
)
)
lazy val commonSettings = Seq(
headerLicense := Some(HeaderLicense.Custom(header))
) ++ scalaMacroDependencies
lazy val commonJsSettings = Seq()
lazy val commonJvmSettings = Seq()
ThisBuild / tlSiteApiUrl := Some(url("https://www.javadoc.io/doc/org.typelevel/spire_2.13/latest/spire/index.html"))
lazy val coreSettings = Seq(
Compile / sourceGenerators += (Compile / genProductTypes).taskValue,
genProductTypes := {
val scalaSource = (Compile / sourceManaged).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()
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 munitSettings = Seq(
libraryDependencies ++= Seq(
"org.scalameta" %%% "munit" % munit % Test,
"org.typelevel" %%% "discipline-munit" % munitDiscipline % Test
)
)
lazy val spireSettings = buildSettings ++ commonSettings ++ commonDeps
lazy val unidocSettings = Seq(
ScalaUnidoc / unidoc / unidocProjectFilter := inAnyProject -- inProjects(examples, benchmark, tests.jvm)
)
lazy val scalaMacroDependencies: Seq[Setting[_]] = Seq(
libraryDependencies ++= {
if (scalaVersion.value.startsWith("3")) Seq.empty
else Seq(scalaOrganization.value % "scala-reflect" % scalaVersion.value % "provided")
}
)