-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
260 lines (239 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
ThisBuild / semanticdbEnabled := false
ThisBuild / scalaVersion := props.ProjectScalaVersion
ThisBuild / organization := "io.kevinlee"
ThisBuild / developers := List(
Developer(
props.GitHubUsername,
"Kevin Lee",
"kevin.code@kevinlee.io",
url(s"https://github.com/${props.GitHubUsername}"),
)
)
ThisBuild / homepage := url(s"https://github.com/${props.GitHubUsername}/${props.RepoName}").some
ThisBuild / scmInfo :=
ScmInfo(
url(s"https://github.com/${props.GitHubUsername}/${props.RepoName}"),
s"git@github.com:${props.GitHubUsername}/${props.RepoName}.git"
).some
ThisBuild / licenses := props.licenses
ThisBuild / resolvers += props.SonatypeSnapshots
libraryDependencies := (
if (isScala3(scalaVersion.value))
libraryDependencies
.value
.filterNot(props.removeDottyIncompatible)
else
libraryDependencies.value
)
lazy val core = module("core")
.settings(
semanticdbEnabled := false,
description := "Just FP Lib - Core",
crossScalaVersions := props.CrossScalaVersions,
Compile / unmanagedSourceDirectories ++= {
val sharedSourceDir = baseDirectory.value / "src/main"
if (scalaVersion.value.startsWith("2.10") || scalaVersion.value.startsWith("2.11"))
List(sharedSourceDir / "scala-2.10_2.11")
else if (scalaVersion.value.startsWith("2.12"))
List(
sharedSourceDir / "scala-2.12_2.13",
sharedSourceDir / "scala-2.12_3.0",
)
else if (scalaVersion.value.startsWith("2.13"))
List(
sharedSourceDir / "scala-2.12_2.13",
sharedSourceDir / "scala-2.12_3.0",
sharedSourceDir / "scala-2.13_3.0",
)
else if (isScala3(scalaVersion.value))
List(
sharedSourceDir / "scala-2.12_3.0",
sharedSourceDir / "scala-2.13_3.0",
)
else
Seq.empty
},
scalacOptions :=
(if (isScala3(scalaVersion.value))
List(
"-source:3.0-migration",
"-Ykind-projector",
"-language:" + List(
"dynamics",
"existentials",
"higherKinds",
"reflectiveCalls",
"experimental.macros",
"implicitConversions",
).mkString(","),
)
else
scalacOptions.value),
addCompilerPlugin("org.typelevel" % "kind-projector" % "0.11.3" cross CrossVersion.full),
/* Ammonite-REPL { */
libraryDependencies ++=
(scalaBinaryVersion.value match {
case "2.10" =>
Seq.empty[ModuleID]
case "2.11" =>
List("com.lihaoyi" % "ammonite" % "1.6.7-2-c28002d" % Test cross CrossVersion.full)
case "2.12" =>
List("com.lihaoyi" % "ammonite" % "2.3.8-58-aa8b2ab1" % Test cross CrossVersion.full)
case "2.13" =>
List("com.lihaoyi" % "ammonite" % "2.5.9" % Test cross CrossVersion.full)
case _ =>
Seq.empty[ModuleID]
}),
libraryDependencies ++= libs.hedgehogLibs,
libraryDependencies := (
if (isScala3(scalaVersion.value)) {
libraryDependencies
.value
.filterNot(props.removeDottyIncompatible)
} else
(libraryDependencies).value
),
Test / sourceGenerators +=
(scalaBinaryVersion.value match {
case "2.10" =>
task(Seq.empty[File])
case "2.11" | "2.12" =>
task {
val file = (Test / sourceManaged).value / "amm.scala"
IO.write(file, """object amm extends App { ammonite.Main.main(args) }""")
List(file)
}
case "2.13" =>
task {
val file = (Test / sourceManaged).value / "amm.scala"
IO.write(file, """object amm extends App { ammonite.AmmoniteMain.main(args) }""")
List(file)
}
case _ =>
task(Seq.empty[File])
}),
/* } Ammonite-REPL */
// , Compile / compile / wartremoverErrors ++= commonWarts((update / scalaBinaryVersion).value)
// , Test / compile / wartremoverErrors ++= commonWarts((update / scalaBinaryVersion).value)
// , wartremoverErrors ++= commonWarts((update / scalaBinaryVersion).value)
// , wartremoverErrors ++= Warts.all
// , Compile / console / wartremoverErrors := List.empty
Compile / console / scalacOptions := (console / scalacOptions).value.filterNot(_.contains("wartremover")),
// Test / console / wartremoverErrors := List.empty,
Test / console / scalacOptions := (console / scalacOptions).value.filterNot(_.contains("wartremover")),
testFrameworks ++= List(TestFramework("hedgehog.sbt.Framework")),
/* Bintray { */
licenses := List("MIT" -> url("http://opensource.org/licenses/MIT")),
/* } Bintray */
console / initialCommands :=
"""import just.fp._; import just.fp.syntax._""",
/* Coveralls { */
coverageHighlighting := (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 10)) =>
false
case _ =>
true
})
/* } Coveralls */
)
lazy val docs = (project in file("generated-docs"))
.enablePlugins(MdocPlugin, DocusaurPlugin)
.settings(
name := prefixedProjectName("docs"),
mdocVariables := Map(
"VERSION" -> {
import sys.process._
"git fetch --tags".!
val tag = "git rev-list --tags --max-count=1".!!.trim
s"git describe --tags $tag".!!.trim.stripPrefix("v")
},
"SUPPORTED_SCALA_VERSIONS" -> {
val versions = props
.CrossScalaVersions
.map(CrossVersion.binaryScalaVersion)
.map(binVer => s"`$binVer`")
if (versions.length > 1)
s"${versions.init.mkString(", ")} and ${versions.last}"
else
versions.mkString
},
),
docusaurDir := (ThisBuild / baseDirectory).value / "website",
docusaurBuildDir := docusaurDir.value / "build",
gitHubPagesOrgName := props.GitHubUsername,
gitHubPagesRepoName := props.RepoName,
libraryDependencies := (
if (isScala3(scalaVersion.value))
libraryDependencies
.value
.filterNot(props.removeDottyIncompatible)
else
libraryDependencies.value
),
)
.settings(noPublish)
.dependsOn(core)
lazy val justFp = (project in file("."))
.enablePlugins(DevOopsGitHubReleasePlugin)
.settings(
name := prefixedProjectName(""),
description := "Just FP Lib",
semanticdbEnabled := false,
devOopsPackagedArtifacts := List(
s"*/target/scala-*/${name.value}*.jar",
),
)
.settings(mavenCentralPublishSettings)
.settings(noPublish)
.settings(noDoc)
.aggregate(core)
lazy val props =
new {
val DottyVersions = List("3.0.0")
val ProjectScalaVersion = "2.13.11"
val SonatypeCredentialHost = "s01.oss.sonatype.org"
val SonatypeRepository = s"https://$SonatypeCredentialHost/service/local"
val SonatypeSnapshots = "sonatype-snapshots" at s"https://$SonatypeCredentialHost/content/repositories/snapshots"
val licenses = List(License.MIT)
val removeDottyIncompatible: ModuleID => Boolean =
m =>
m.name == "wartremover" ||
m.name == "ammonite" ||
m.name == "kind-projector" ||
m.name == "mdoc"
val CrossScalaVersions: Seq[String] =
(List(
"2.11.12",
"2.12.12",
"2.13.10"
) ++ DottyVersions).distinct
val GitHubUsername = "Kevin-Lee"
val RepoName = "just-fp"
val ProjectName = RepoName
val hedgehogVersion = "0.8.0"
}
lazy val libs =
new {
lazy val hedgehogLibs: List[ModuleID] = List(
"qa.hedgehog" %% "hedgehog-core" % props.hedgehogVersion % Test,
"qa.hedgehog" %% "hedgehog-runner" % props.hedgehogVersion % Test,
"qa.hedgehog" %% "hedgehog-sbt" % props.hedgehogVersion % Test,
)
}
lazy val mavenCentralPublishSettings: SettingsDefinition = List(
/* Publish to Maven Central { */
sonatypeCredentialHost := props.SonatypeCredentialHost,
sonatypeRepository := props.SonatypeRepository,
/* } Publish to Maven Central */
)
def prefixedProjectName(name: String) =
s"${props.ProjectName}${if (name.isEmpty) "" else s"-$name"}"
def isScala3(scalaVersion: String): Boolean = scalaVersion.startsWith("3.")
def module(projectName: String) = {
val prefixedName = prefixedProjectName(projectName)
Project(projectName, file(s"modules/$prefixedName"))
.settings(
name := prefixedName,
)
.settings(mavenCentralPublishSettings)
}