forked from atnos-org/eff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
337 lines (286 loc) · 11 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
import com.typesafe.sbt.SbtSite.SiteKeys._
import com.typesafe.sbt.SbtGhPages.GhPagesKeys._
import ReleaseTransformations._
import ScoverageSbtPlugin._
import com.ambiata.promulgate.project.ProjectPlugin.promulgate
import org.scalajs.sbtplugin.cross.CrossType
import Defaults.{defaultTestTasks, testTaskOptions}
import sbtrelease._
lazy val eff = project.in(file("."))
.settings(moduleName := "root")
.settings(effSettings)
.settings(noPublishSettings)
.aggregate(coreJVM, coreJS, macros, monixJVM, monixJS, scalaz, twitter, fs2JS, fs2JVM)
.dependsOn(coreJVM, coreJS, macros, monixJVM, monixJS, scalaz, twitter, fs2JS, fs2JVM)
lazy val core = crossProject.crossType(CrossType.Full).in(file("."))
.settings(moduleName := "eff")
.jsSettings(commonJsSettings:_*)
.jvmSettings(commonJvmSettings ++ Seq(libraryDependencies ++= scalameter):_*)
.jvmSettings(promulgate.library("org.atnos.eff", "eff"):_*)
.jvmSettings(notesSettings:_*)
.settings(effSettings:_*)
lazy val coreJVM = core.jvm
lazy val coreJS = core.js
lazy val macros = project.in(file("macros"))
.settings(moduleName := "eff-macros")
.dependsOn(coreJVM)
.settings(libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value)
.settings(addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.patch))
.settings(commonJvmSettings)
.settings(effSettings:_*)
lazy val monix = crossProject.crossType(CrossType.Full).in(file("monix"))
.settings(moduleName := "eff-monix")
.dependsOn(core)
.settings(libraryDependencies ++= monixEval)
.settings(effSettings:_*)
.jvmSettings(commonJvmSettings:_*)
.jsSettings(commonJsSettings ++ Seq(libraryDependencies ++= monixJs):_*)
lazy val monixJVM = monix.jvm
lazy val monixJS = monix.js
lazy val scalaz = project.in(file("scalaz"))
.settings(moduleName := "eff-scalaz")
.dependsOn(coreJVM)
.settings(libraryDependencies ++= scalazConcurrent)
.settings(libraryDependencies ++= specs2Scalaz)
.settings(effSettings ++ commonJvmSettings:_*)
lazy val fs2 = crossProject.crossType(CrossType.Full).in(file("fs2"))
.settings(moduleName := "eff-fs2")
.dependsOn(core)
.settings(effSettings:_*)
.jvmSettings(commonJvmSettings ++ Seq(libraryDependencies ++= fs2Jvm):_*)
.jsSettings(commonJsSettings ++ Seq(libraryDependencies ++= fs2Js):_*)
lazy val fs2JVM = fs2.jvm
lazy val fs2JS = fs2.js
lazy val twitter = project
.settings(moduleName := "eff-twitter")
.dependsOn(coreJVM)
.settings(libraryDependencies ++= twitterUtilCore ++ catbird)
.settings(effSettings ++ commonJvmSettings:_*)
lazy val scoverageSettings = Seq(
coverageMinimum := 60,
coverageFailOnMinimum := false,
coverageHighlighting := true,
coverageExcludedPackages := "org\\.atnos\\.eff\\.bench\\..*"
)
lazy val buildSettings = Seq(
organization := "org.atnos",
scalaVersion := "2.12.2",
crossScalaVersions := Seq("2.11.11", scalaVersion.value)
)
lazy val commonSettings = Seq(
scalacOptions ++= commonScalacOptions,
resolvers ++= commonResolvers,
scalacOptions in (Compile, doc) := (scalacOptions in (Compile, doc)).value.filter(_ != "-Xfatal-warnings"),
addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.3")
) ++ warnUnusedImport ++ prompt
lazy val tagName = Def.setting{
s"v${if (releaseUseGlobalVersion.value) (version in ThisBuild).value else version.value}"
}
lazy val commonJsSettings = Seq(
scalaJSStage in Global := FastOptStage,
parallelExecution := false,
requiresDOM := false,
libraryDependencies ++= catsJs,
jsEnv := NodeJSEnv().value
) ++ disableTests
def disableTests = Seq(
test := {},
testQuick := {},
testOnly := {}
)
lazy val commonJvmSettings = Seq(
(scalacOptions in Test) ~= (_.filterNot(_ == "-Xfatal-warnings")),
libraryDependencies ++= catsJvm,
libraryDependencies ++= specs2
) ++ Seq(scalacOptions in Test ++= Seq("-Yrangepos"))
lazy val effSettings =
buildSettings ++ commonSettings ++ publishSettings ++ scoverageSettings
lazy val publishSettings =
Seq(
homepage := Some(url("https://github.com/atnos-org/eff")),
licenses := Seq("MIT" -> url("http://opensource.org/licenses/MIT")),
scmInfo := Some(ScmInfo(url("https://github.com/atnos-org/eff"), "scm:git:[email protected]:atnos-org/eff.git")),
autoAPIMappings := true,
apiURL := Some(url("http://atnos.org/eff/api/")),
pomExtra := (
<developers>
<developer>
<id>etorreborre</id>
<name>Eric Torreborre</name>
<url>https://github.com/etorreborre/</url>
</developer>
</developers>
)
) ++ credentialSettings ++ sharedPublishSettings ++ sharedReleaseProcess
lazy val noPublishSettings = Seq(
publish := (),
publishLocal := (),
publishArtifact := false
)
lazy val commonScalacOptions = Seq(
"-deprecation",
"-encoding", "UTF-8",
"-feature",
"-language:_",
"-unchecked",
"-Xfatal-warnings",
"-Xlint",
"-Xlint:-nullary-unit",
"-Yno-adapted-args",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-Ypartial-unification",
"-Xfuture"
)
lazy val sharedPublishSettings = Seq(
releaseCrossBuild := true,
releaseTagName := tagName.value,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
publishMavenStyle := true,
publishArtifact in Test := false,
pomIncludeRepository := Function.const(false),
publishTo := Option("Releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2")
) ++ site.settings ++
ghpages.settings ++
userGuideSettings
lazy val userGuideSettings =
Seq(
GhPagesKeys.ghpagesNoJekyll := false,
SiteKeys.siteSourceDirectory in SiteKeys.makeSite := target.value / "specs2-reports" / "site",
includeFilter in SiteKeys.makeSite := "*.html" | "*.css" | "*.png" | "*.jpg" | "*.gif" | "*.js",
git.remoteRepo := "[email protected]:atnos-org/eff.git"
)
lazy val sharedReleaseProcess = Seq(
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies
, inquireVersions
, runTest
, setReleaseVersion
, commitReleaseVersion
, tagRelease
, generateWebsite
, publishSite
, publishArtifacts
, setNextVersion
, commitNextVersion
, ReleaseStep(action = Command.process("sonatypeReleaseAll", _), enableCrossBuild = true)
, pushChanges
)
) ++
Seq(
releaseNextVersion := { v => Version(v).map(_.bumpBugfix.string).getOrElse(versionFormatError) },
releaseTagName := "EFF-" + releaseVersion.value(version.value)
) ++
testTaskDefinition(generateWebsiteTask, Seq(Tests.Filter(_.endsWith("Website"))))
lazy val publishSite = ReleaseStep { st: State =>
val st2 = executeStepTask(makeSite, "Making the site")(st)
executeStepTask(pushSite, "Publishing the site")(st2)
}
lazy val notesSettings = Seq(
ghreleaseRepoOrg := "atnos-org",
ghreleaseRepoName := "eff",
ghreleaseTitle := { tagName: TagName => s"eff ${tagName.replace("EFF-", "")}" },
ghreleaseIsPrerelease := { tagName: TagName => false },
ghreleaseNotes := { tagName: TagName =>
// find the corresponding release notes
val notesFilePath = s"notes/${tagName.replace("EFF-", "")}.markdown"
try io.Source.fromFile(notesFilePath).mkString
catch { case t: Throwable => throw new Exception(s"$notesFilePath not found") }
},
// just upload the notes
ghreleaseAssets := Seq()
)
lazy val generateWebsiteTask = TaskKey[Tests.Output]("generate-website", "generate the website")
lazy val generateWebsite = executeStepTask(generateWebsiteTask, "Generating the website", Test)
lazy val warnUnusedImport = Seq(
scalacOptions in (Compile, console) ~= {_.filterNot("-Ywarn-unused-import" == _)},
scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value
)
lazy val credentialSettings = Seq(
// For Travis CI - see http://www.cakesolutions.net/teamblogs/publishing-artefacts-to-oss-sonatype-nexus-using-sbt-and-travis-ci
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
)
lazy val prompt = shellPrompt in ThisBuild := { state =>
val name = Project.extract(state).currentRef.project
(if (name == "eff") "" else name) + "> "
}
def executeTask(task: TaskKey[_], info: String) = (st: State) => {
st.log.info(info)
val extracted = Project.extract(st)
val ref: ProjectRef = extracted.get(thisProjectRef)
extracted.runTask(task in ref, st)._1
}
def executeStepTask(task: TaskKey[_], info: String, configuration: Configuration) = ReleaseStep { st: State =>
executeTask(task, info, configuration)(st)
}
def executeStepTask(task: TaskKey[_], info: String) = ReleaseStep { st: State =>
executeTask(task, info)(st)
}
def executeTask(task: TaskKey[_], info: String, configuration: Configuration) = (st: State) => {
st.log.info(info)
Project.extract(st).runTask(task in configuration, st)._1
}
def testTaskDefinition(task: TaskKey[Tests.Output], options: Seq[TestOption]) =
Seq(testTask(task)) ++
inScope(GlobalScope)(defaultTestTasks(task)) ++
inConfig(Test)(testTaskOptions(task)) ++
(testOptions in (Test, task) ++= options)
def testTask(task: TaskKey[Tests.Output]) =
task := Def.taskDyn {
Def.task(
Defaults.allTestGroupsTask(
(streams in Test).value,
(loadedTestFrameworks in Test).value,
(testLoader in Test).value,
(testGrouping in Test in test).value,
(testExecution in Test in task).value,
(fullClasspath in Test in test).value,
(javaHome in test).value
)).flatMap(identity)
}.value
lazy val catsVersion = "0.9.0"
lazy val monixVersion = "2.3.0"
lazy val scalazVersion = "7.2.7"
lazy val fs2Version = "0.9.6"
lazy val specs2Version = "3.9.4"
lazy val twitterUtilVersion = "6.42.0"
lazy val catbirdVersion = "0.13.0"
lazy val catsJvm = Seq(
"org.typelevel" %% "cats-core" % catsVersion)
lazy val catsJs = Seq(
"org.typelevel" %%%! "cats-core" % catsVersion)
lazy val monixEval = Seq(
"io.monix" %% "monix-eval" % monixVersion,
"io.monix" %% "monix-cats" % monixVersion)
lazy val monixJs = Seq(
"io.monix" %%%! "monix-eval" % monixVersion,
"io.monix" %%%! "monix-cats" % monixVersion)
lazy val scalazConcurrent = Seq(
"org.scalaz" %% "scalaz-concurrent" % scalazVersion)
lazy val specs2Scalaz = Seq(
"org.specs2" %% "specs2-scalaz" % specs2Version % "test")
lazy val fs2Jvm = Seq(
"co.fs2" %% "fs2-core" % fs2Version)
lazy val fs2Js = Seq(
"co.fs2" %%%! "fs2-core" % fs2Version)
lazy val specs2 = Seq(
"org.specs2" %% "specs2-core"
, "org.specs2" %% "specs2-matcher-extra"
, "org.specs2" %% "specs2-scalacheck"
, "org.specs2" %% "specs2-html"
, "org.specs2" %% "specs2-junit").map(_ % specs2Version % "test")
lazy val scalameter = Seq(
"com.storm-enroute" %% "scalameter" % "0.8.2" % "test")
lazy val twitterUtilCore = Seq(
"com.twitter" %% "util-collection" % twitterUtilVersion
)
lazy val catbird = Seq(
"io.catbird" %% "catbird-util" % catbirdVersion
)
lazy val commonResolvers = Seq(
Resolver.sonatypeRepo("releases")
, Resolver.typesafeRepo("releases")
, Resolver.url("ambiata-oss", new URL("https://ambiata-oss.s3.amazonaws.com"))(Resolver.ivyStylePatterns))