-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.sbt
272 lines (234 loc) · 8.4 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
import com.typesafe.tools.mima.plugin.MimaPlugin.mimaDefaultSettings
import microsites.{CdnDirectives, MicrositeEditButton}
import sbtorgpolicies.utils.getEnvVar
import wartremover.Wart
Global / onChangedBuildSource := ReloadOnSourceChanges
/* dependency versions */
lazy val V = new {
val algebird = "0.13.6"
val cats = "2.1.0"
val evilplot = "0.7.0"
val kindProjector = "0.10.3"
val rainier = "0.2.3"
val scala = "2.12.13"
val scalacheck = "1.15.3"
val scalatest = "3.1.0"
val scalaTestPlus = "3.1.0.1"
val util = "21.2.0"
}
lazy val docsSourcesAndProjects: Seq[ProjectReference] =
Seq(rlCore, rlPlot, rlBook)
val compilerOptions = Seq(
"-unchecked",
"-deprecation",
"-Xlint",
"-language:implicitConversions",
"-language:higherKinds",
"-language:existentials"
)
// The console can't handle these.
val consoleExclusions = Seq(
"-Ywarn-unused:imports", "-Xfatal-warnings", "-Xlint"
)
val ignoredWarts: Set[Wart] =
Set(Wart.DefaultArguments, Wart.TraversableOps, Wart.Any, Wart.NonUnitStatements)
def unsafeWartsExcept(ws: Set[wartremover.Wart]): Seq[wartremover.Wart] =
Warts.unsafe.filterNot(w => ws.exists(_.clazz == w.clazz))
val sharedSettings = Seq(
organization := "io.samritchie",
scalaVersion := V.scala,
// Lets me C-c out of the running process.
cancelable in Global := true,
parallelExecution in Test := true,
scalafmtOnCompile in ThisBuild := true,
wartremoverErrors in (ThisBuild, compile) ++= unsafeWartsExcept(ignoredWarts),
unmanagedBase in Global := baseDirectory.value / "lib",
resolvers ++= Seq(
Resolver.bintrayRepo("cibotech", "public")
),
scalacOptions ++= Seq(
"-unchecked",
"-deprecation",
"-Xlint",
"-language:implicitConversions",
"-language:higherKinds",
"-language:existentials"),
scalacOptions in (Compile, console) --= consoleExclusions,
scalacOptions in (Test, console) --= consoleExclusions,
// Publishing options:
releaseCrossBuild := true,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
releaseVersionBump := sbtrelease.Version.Bump.Minor, // need to tweak based on mima results
publishMavenStyle := true,
publishArtifact in Test := false,
pomIncludeRepository := { x => false },
publishTo := Some(
if (version.value.trim.endsWith("SNAPSHOT"))
Opts.resolver.sonatypeSnapshots
else
Opts.resolver.sonatypeStaging
),
scmInfo := Some(
ScmInfo(
url("https://github.com/sritchie/scala-rl"),
"scm:git@github.com:sritchie/scala-rl.git"
)
),
pomExtra := (
<url>https://github.com/sritchie/scala-rl</url>
<licenses>
<license>
<name>Apache 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>
<developers>
<developer>
<id>sritchie</id>
<name>Sam Ritchie</name>
<url>https://www.samritchie.io</url>
</developer>
</developers>)
) ++ mimaDefaultSettings
lazy val noPublishSettings = Seq(
publish := {},
publishLocal := {},
test := {},
publishArtifact := false
)
/**
* This returns the previous jar I've released that is compatible
* with the current.
*/
val noBinaryCompatCheck = Set[String]("core")
def previousVersion(subProj: String) =
Some(subProj)
.filterNot(noBinaryCompatCheck.contains(_))
.map { s => "io.sritchie" %% ("scala-rl-" + s) % "0.0.1" }
lazy val rl = Project(
id = "scala-rl",
base = file("."))
.settings(sharedSettings)
.settings(noPublishSettings)
.aggregate(rlCore, rlBook, rlPlot, rlWorld)
def module(name: String) = {
val id = "scala-rl-%s".format(name)
Project(id = id, base = file(id)).settings(sharedSettings ++ Seq(
Keys.name := id,
mimaPreviousArtifacts := previousVersion(name).toSet)
)
}
lazy val rlCore = module("core").settings(
libraryDependencies ++= Seq(
"com.stripe" %% "rainier-cats" % V.rainier,
"com.stripe" %% "rainier-core" % V.rainier,
// For the monoids and implementations.
"com.twitter" %% "algebird-core" % V.algebird,
"com.twitter" %% "util-core" % V.util,
// For its typeclasses, Monad specifically.
"org.typelevel" %% "cats-core" % V.cats,
"org.typelevel" %% "cats-free" % V.cats,
// Testing.
"com.twitter" %% "algebird-test" % V.algebird % Test,
"org.scalatest" %% "scalatest" % V.scalatest % Test,
"org.scalacheck" %% "scalacheck" % V.scalacheck % Test,
"org.scalatestplus" %% "scalacheck-1-14" % V.scalaTestPlus % Test
) ++ Seq(compilerPlugin("org.typelevel" %% "kind-projector" % V.kindProjector)),
)
lazy val rlWorld = module("world").settings(
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % V.scalatest % Test,
"org.scalacheck" %% "scalacheck" % V.scalacheck % Test
)
).dependsOn(rlCore)
lazy val rlPlot = module("plot").settings(
libraryDependencies ++= Seq(
// Charts.
"com.cibo" %% "evilplot" % V.evilplot,
"com.cibo" %% "evilplot-repl" % V.evilplot,
)
).dependsOn(rlCore)
lazy val rlBook = module("book").settings(
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % V.scalatest % Test,
"org.scalacheck" %% "scalacheck" % V.scalacheck % Test
),
initialCommands :=
"""
import com.scalarl._
import com.stripe.rainier.sampler.RNG
import com.stripe.rainier.compute.{Evaluator, Real}
implicit val rng: RNG = RNG.default
implicit val evaluator: Numeric[Real] = new Evaluator(Map.empty)
""".stripMargin('|'),
mainClass in (Compile, run) := Some("scalarl.book.Chapter2"),
).dependsOn(rlCore, rlPlot, rlWorld)
lazy val docsMappingsAPIDir = settingKey[String]("Name of subdirectory in site target directory for api docs")
lazy val docSettings = Seq(
micrositeName := "ScalaRL",
micrositeDescription := "Reinforcement Learning in Scala.",
micrositeAuthor := "Sam Ritchie",
micrositeUrl := "http://www.scalarl.com",
micrositeDocumentationUrl := "/api/com/scalarl/index.html",
micrositeHomepage := "http://www.scalarl.com/",
micrositeOrganizationHomepage := "https://www.samritchie.io",
micrositeTwitter := "@scalaRLProject",
micrositeTwitterCreator := "@sritchie",
micrositeGitterChannelUrl := "ScalaRL/community",
micrositeGithubOwner := "sritchie",
micrositeGithubRepo := "scala-rl",
micrositeAnalyticsToken := "UA-146772284-1",
micrositeExtraMdFiles := Map(
file("CONTRIBUTING.md") ->
microsites.ExtraMdFileConfig(
"contributing.md",
"page",
Map("title" -> "Contributing", "section" -> "contributing", "position" -> "5")
)),
micrositeEditButton := Some(
MicrositeEditButton(
"Help us improve this page",
"/edit/develop/docs/src/main/tut/{{ page.path }}")),
micrositeHighlightTheme := "atom-one-light",
micrositePalette := Map(
"brand-primary" -> "#5B5988",
"brand-secondary" -> "#292E53",
"brand-tertiary" -> "#222749",
"gray-dark" -> "#49494B",
"gray" -> "#7B7B7E",
"gray-light" -> "#E5E5E6",
"gray-lighter" -> "#F4F3F4",
"white-color" -> "#FFFFFF"),
autoAPIMappings := true,
unidocProjectFilter in (ScalaUnidoc, unidoc) :=
inProjects(docsSourcesAndProjects:_*),
docsMappingsAPIDir := "api",
addMappingsToSiteDir(mappings in (ScalaUnidoc, packageDoc), docsMappingsAPIDir),
ghpagesNoJekyll := false,
// Don't kill the cname redirect.
excludeFilter in ghpagesCleanSite :=
new FileFilter{
def accept(f: File) = (ghpagesRepository.value / "CNAME").getCanonicalPath == f.getCanonicalPath
} || "versions.html",
fork in tut := true,
fork in (ScalaUnidoc, unidoc) := true,
scalacOptions in (ScalaUnidoc, unidoc) ++= Seq(
"-doc-source-url", "https://github.com/sritchie/scala-rl/tree/develop€{FILE_PATH}.scala",
"-sourcepath", baseDirectory.in(LocalRootProject).value.getAbsolutePath,
// "-diagrams", // Not working locally; wait until graphviz is reliable.
"-doc-root-content", "scaladoc-root.txt"
),
git.remoteRepo := "git@github.com:sritchie/scala-rl.git"
)
// Documentation is generated for projects defined in
// `docsSourcesAndProjects`.
lazy val docs = project
.enablePlugins(MicrositesPlugin, TutPlugin, ScalaUnidocPlugin, GhpagesPlugin)
.settings(moduleName := "scala-rl-docs")
.settings(sharedSettings)
.settings(noPublishSettings)
.settings(docSettings)
.settings((scalacOptions in Tut) ~= (_.filterNot(Set("-Ywarn-unused-import", "-Ywarn-dead-code"))))
.dependsOn(rlCore, rlPlot, rlBook, rlWorld)