-
Notifications
You must be signed in to change notification settings - Fork 22
/
build.sbt
257 lines (231 loc) · 10 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
import ReleaseTransformations._
import com.lightbend.paradox.ParadoxProcessor
lazy val contributors = Seq(
"Mathias Doenitz" -> "sirthias")
lazy val commonSettings = Seq( // reformatOnCompileSettings ++ Seq(
organization := "io.swave",
scalaVersion := "2.12.1",
crossScalaVersions := Seq("2.12.1", "2.11.8"),
homepage := Some(url("http://swave.cc")),
description := "A Reactive Streams infrastructure implementation in Scala",
startYear := Some(2016),
licenses := Seq("MPL 2.0" -> new URL("https://www.mozilla.org/en-US/MPL/2.0/")),
javacOptions ++= commonJavacOptions,
scalacOptions ++= commonScalacOptions,
scalacOptions in Test ~= (_ filterNot (_ == "-Ywarn-value-discard")),
scalacOptions in (Compile, console) ~= { _ filterNot { o => o == "-Ywarn-unused-import" || o == "-Xfatal-warnings" } },
scalacOptions in (Test, console) ~= { _ filterNot { o => o == "-Ywarn-unused-import" || o == "-Xfatal-warnings" } },
scalacOptions in (Compile, doc) ~= { _.filterNot(o => o == "-Xlint" || o == "-Xfatal-warnings") :+ "-nowarn" },
initialCommands in console := """import swave.core._""",
scmInfo := Some(ScmInfo(url("https://github.com/sirthias/swave"), "scm:git:[email protected]:sirthias/swave.git")),
// code formatting
headers := Map("scala" -> de.heikoseeberger.sbtheader.license.MPLv2_NoCopyright("", "")),
// test coverage
coverageMinimum := 90,
coverageFailOnMinimum := false,
coverageExcludedPackages := """swave\.benchmarks\..*;swave\.examples\..*""")
lazy val publishingSettings = Seq(
useGpg := true,
publishMavenStyle := true,
publishArtifact in Test := false,
pomIncludeRepository := { _ => false },
publishTo := Some {
val nexus = "https://oss.sonatype.org/"
if (version.value.trim endsWith "SNAPSHOT") "snapshots" at nexus + "content/repositories/snapshots"
else "releases" at nexus + "service/local/staging/deploy/maven2"
},
pomExtra :=
<developers>
{for ((name, username) <- contributors)
yield <developer><id>{username}</id><name>{name}</name><url>http://github.com/{username}</url></developer>
}
</developers>)
lazy val noPublishingSettings = Seq(
publish := (),
publishLocal := (),
publishArtifact := false)
lazy val releaseSettings = {
val runCompile = ReleaseStep(
action = { st: State =>
val extracted = Project.extract(st)
val ref = extracted.get(thisProjectRef)
extracted.runAggregated(compile in Compile in ref, st)
})
Seq(
releaseCrossBuild := true,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runCompile,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
publishArtifacts,
setNextVersion,
commitNextVersion,
releaseStepCommand("sonatypeReleaseAll"),
pushChanges))
}
lazy val commonJavacOptions = Seq(
"-encoding", "UTF-8",
"-Xlint:unchecked",
"-Xlint:deprecation")
lazy val commonScalacOptions = Seq(
"-deprecation",
"-encoding", "UTF-8",
"-feature",
"-language:_",
"-unchecked",
"-Xfatal-warnings",
"-Xlint",
"-Xfuture",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-inaccessible",
"-Ywarn-infer-any",
"-Ywarn-nullary-override",
"-Ywarn-nullary-unit",
"-Ywarn-numeric-widen",
"-Ywarn-unused-import",
"-Ywarn-value-discard")
lazy val macroParadise =
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)
/////////////////////// DEPENDENCIES /////////////////////////
// core
val `reactive-streams` = "org.reactivestreams" % "reactive-streams" % "1.0.0"
val `jctools-core` = "org.jctools" % "jctools-core" % "2.0.1"
val `typesafe-config` = "com.typesafe" % "config" % "1.3.1"
val shapeless = "com.chuusai" %% "shapeless" % "2.3.2"
val `scala-logging` = "com.typesafe.scala-logging" %% "scala-logging" % "3.5.0"
// *-compat
val `akka-stream` = "com.typesafe.akka" %% "akka-stream" % "2.4.17"
val `scodec-bits` = "org.scodec" %% "scodec-bits" % "1.1.4"
// test
val scalatest = "org.scalatest" %% "scalatest" % "3.0.1" % "test"
val `reactive-streams-tck` = "org.reactivestreams" % "reactive-streams-tck" % "1.0.0" % "test"
// examples
val logback = "ch.qos.logback" % "logback-classic" % "1.2.3"
/////////////////////// PROJECTS /////////////////////////
lazy val swave = project.in(file("."))
.aggregate(benchmarks, `compat-akka`, `compat-scodec`, core, `core-macros`, `core-tests`, docs, testkit)
.settings(commonSettings: _*)
.settings(releaseSettings: _*)
.settings(noPublishingSettings: _*)
lazy val benchmarks = project
.dependsOn(core)
.enablePlugins(AutomateHeaderPlugin)
.disablePlugins(BackgroundRunPlugin)
.settings(commonSettings: _*)
.settings(noPublishingSettings: _*)
.settings(
fork in run := true,
libraryDependencies ++= Seq(`akka-stream`, logback)
)
lazy val `compat-akka` = project
.dependsOn(core, `core-macros` % "compile-internal")
.enablePlugins(AutomateHeaderPlugin)
.settings(commonSettings: _*)
.settings(releaseSettings: _*)
.settings(publishingSettings: _*)
.settings(
moduleName := "swave-akka-compat",
libraryDependencies ++= Seq(`akka-stream`, scalatest))
lazy val `compat-scodec` = project
.dependsOn(core, `core-macros` % "compile-internal")
.enablePlugins(AutomateHeaderPlugin)
.settings(commonSettings: _*)
.settings(releaseSettings: _*)
.settings(publishingSettings: _*)
.settings(
moduleName := "swave-scodec-compat",
libraryDependencies ++= Seq(`scodec-bits`, scalatest, logback % "test"))
lazy val core = project
.dependsOn(`core-macros` % "compile-internal, test-internal")
.enablePlugins(AutomateHeaderPlugin)
.settings(commonSettings: _*)
.settings(releaseSettings: _*)
.settings(publishingSettings: _*)
.settings(
moduleName := "swave-core",
macroParadise,
libraryDependencies ++= Seq(`reactive-streams`, `jctools-core`, `typesafe-config`, shapeless, `scala-logging`,
scalatest))
lazy val `core-macros` = project
.enablePlugins(AutomateHeaderPlugin)
.settings(commonSettings: _*)
.settings(noPublishingSettings: _*)
.settings(
macroParadise,
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value)
lazy val `core-tests` = project
.dependsOn(core % "test->test", testkit, `core-macros` % "test-internal", `compat-scodec` % "test")
.enablePlugins(AutomateHeaderPlugin)
.settings(commonSettings: _*)
.settings(noPublishingSettings: _*)
.settings(
macroParadise,
libraryDependencies ++= Seq(shapeless, scalatest, `reactive-streams-tck`, logback % "test"))
lazy val docs = project
.dependsOn(`compat-akka`, `compat-scodec`, core, testkit)
.enablePlugins(ParadoxSitePlugin, GhpagesPlugin)
.settings(commonSettings: _*)
.settings(noPublishingSettings: _*)
.settings(
git.remoteRepo := scmInfo.value.get.connection.drop("scm:git:".length),
libraryDependencies ++= Seq(shapeless, scalatest, `akka-stream`, logback),
apiURL := Some(url("http://swave.cc/api/")),
paradoxTheme := None,
sourceDirectory in (Paradox, paradox) := sourceDirectory.value / "paradox",
sourceDirectory in (Paradox, paradoxTheme) := sourceDirectory.value / "paradox" / "_template",
paradoxProcessor in Paradox := new ParadoxProcessor(writer = new CustomWriter),
paradoxNavigationDepth := 3,
commands += Command.command("openSite") { state =>
val uri = s"file://${Project.extract(state).get(target in Paradox)}/index.html"
state.log.info(s"Opening browser at $uri ...")
java.awt.Desktop.getDesktop.browse(new java.net.URI(uri))
state
},
fork in (Test, run) := true,
connectInput in (Test, run) := true,
javaOptions in (Test, run) ++= Seq("-XX:+UnlockCommercialFeatures", "-XX:+FlightRecorder"),
paradoxProperties in Paradox ++= Map(
"latest-version" -> "0.7.1",
"scala.binaryVersion" -> scalaBinaryVersion.value,
"scala.version" -> scalaVersion.value,
"github.base_url" -> {
val v = version.value
s"https://github.com/sirthias/swave/tree/${if (v.endsWith("SNAPSHOT")) "master" else "v" + v}"
},
"extref.rfc.base_url" -> "http://tools.ietf.org/html/rfc%s",
"extref.akka.base_url" -> "http://doc.akka.io/docs/akka/2.4/scala/%s.html",
"snip.test.base_dir" -> s"${(sourceDirectory in Test).value}/scala/swave/docs",
"snip.core.base_dir" -> s"${(sourceDirectory in Compile in core).value}/scala/swave/core",
"snip.res.base_dir" -> (resourceDirectory in Compile in core).value.toString,
"image.base_url" -> ".../assets/img",
"scaladoc.org.reactivestreams.base_url" -> "http://www.reactive-streams.org/reactive-streams-1.0.0-javadoc/",
"scaladoc.akka.base_url" -> "http://doc.akka.io/api/akka/2.4/",
"scaladoc.scodec.bits.base_url" -> "http://scodec.org/api/scodec-bits/1.1.2/",
"scaladoc.swave.compat.akka.base_url" -> "http://swave.cc/api/compat-akka/latest/",
"scaladoc.swave.compat.scodec.base_url" -> "http://swave.cc/api/compat-scodec/latest/",
"scaladoc.swave.core.base_url" -> "http://swave.cc/api/core/latest/",
"scaladoc.swave.testkit.base_url" -> "http://swave.cc/api/testkit/latest/"))
.settings({
def apiDocs(p: Project) =
siteMappings ++= {
val n = (name in p).value
for ((f, d) <- (mappings in (p, Compile, packageDoc)).value)
yield f -> s"api/$n/latest/$d"
}
List(apiDocs(`compat-akka`), apiDocs(core), apiDocs(`compat-scodec`), apiDocs(testkit))}: _*)
lazy val testkit = project
.dependsOn(core, `core-macros` % "compile-internal")
.enablePlugins(AutomateHeaderPlugin)
.settings(commonSettings: _*)
.settings(releaseSettings: _*)
.settings(publishingSettings: _*)
.settings(
moduleName := "swave-testkit",
macroParadise)