-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sbt
More file actions
230 lines (199 loc) · 8.1 KB
/
Copy pathbuild.sbt
File metadata and controls
230 lines (199 loc) · 8.1 KB
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
import sbtcrossproject.CrossProject
ThisBuild / scalaVersion := props.ScalaVersion
ThisBuild / organization := props.Org
ThisBuild / organizationName := props.OrgName
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"https://github.com/${props.GitHubUsername}/${props.RepoName}.git",
).some
lazy val justSpinner = (project in file("."))
.enablePlugins(DevOopsGitHubReleasePlugin)
.settings(
name := props.ProjectName,
crossScalaVersions := props.CrossScalaVersions,
)
.settings(noPublish)
.aggregate(
coreJvm,
coreJs,
coreNative,
)
lazy val core = module("core", crossProject(JVMPlatform, JSPlatform, NativePlatform))
.settings(
crossScalaVersions := props.CrossScalaVersions,
libraryDependencies ++= List(
libs.catsCore.value,
libs.effectieCats.value,
),
)
lazy val coreJvm = core.jvm
lazy val coreJs = core.js.settings(jsSettingsForFuture)
lazy val coreNative = core.native.settings(nativeSettings)
lazy val exampleNative = (project in file("modules/example-native"))
.enablePlugins(ScalaNativePlugin)
.settings(
name := prefixedProjectName("example-native"),
scalaVersion := props.ScalaVersion,
Compile / console / scalacOptions :=
(console / scalacOptions)
.value
.filterNot(option => option.contains("wartremover") || option.contains("import")),
scalacOptions ++= List("-no-indent", "-explain"),
// wartremoverErrors ++= Warts.allBut(Wart.Any, Wart.Nothing, Wart.ImplicitConversion, Wart.ImplicitParameter),
// wartremoverErrors ++= Set.empty[Wart],
tpolecatExcludeOptions += org.typelevel.scalacoptions.ScalacOptions.warnNonUnitStatement,
)
.settings(noPublish)
.settings(nativeSettings)
.dependsOn(coreNative)
lazy val exampleJvm = (project in file("modules/example-jvm"))
.settings(
name := prefixedProjectName("example-jvm"),
scalaVersion := props.ScalaVersion,
Compile / unmanagedSourceDirectories += (ThisBuild / baseDirectory).value / "modules" / "example-native" / "src" / "main" / "scala",
Compile / console / scalacOptions :=
(console / scalacOptions)
.value
.filterNot(option => option.contains("wartremover") || option.contains("import")),
scalacOptions ++= List("-no-indent", "-explain"),
tpolecatExcludeOptions += org.typelevel.scalacoptions.ScalacOptions.warnNonUnitStatement,
)
.settings(noPublish)
.dependsOn(coreJvm)
lazy val exampleJs = (project in file("modules/example-js"))
.enablePlugins(ScalaJSPlugin)
.settings(
name := prefixedProjectName("example-js"),
scalaVersion := props.ScalaVersion,
Compile / console / scalacOptions :=
(console / scalacOptions)
.value
.filterNot(option => option.contains("wartremover") || option.contains("import")),
scalacOptions ++= List("-no-indent", "-explain"),
tpolecatExcludeOptions ++= Set(
org.typelevel.scalacoptions.ScalacOptions.warnNonUnitStatement,
org.typelevel.scalacoptions.ScalacOptions.warnValueDiscard,
),
scalaJSUseMainModuleInitializer := true,
)
.settings(jsSettingsForFuture)
.settings(noPublish)
.dependsOn(coreJs)
lazy val props =
new {
private val gitHubRepo = findRepoOrgAndName
val GitHubUsername = gitHubRepo.fold("kevin-lee")(_.orgToString)
val RepoName = gitHubRepo.fold("just-spinner")(_.nameToString)
val ProjectName = RepoName
val ScalaVersion = "3.3.7"
val CrossScalaVersions = List("2.13.18", "3.3.7")
val Org = "io.kevinlee"
val OrgName = "Kevin's Code"
lazy val licenses = List(License.MIT)
val CatsVersion = "2.13.0"
val EffectieVersion = "2.3.0"
val ExtrasVersion = "0.51.0"
val HedgehogVersion = "0.13.0"
val IncludeTest: String = "compile->compile;test->test"
}
lazy val libs =
new {
lazy val catsCore = Def.setting("org.typelevel" %%% "cats-core" % props.CatsVersion)
lazy val effectieCats = Def.setting("io.kevinlee" %%% "effectie-cats" % props.EffectieVersion)
lazy val tests = new {
lazy val hedgehog = Def.setting(
List(
"qa.hedgehog" %%% "hedgehog-core" % props.HedgehogVersion % Test,
"qa.hedgehog" %%% "hedgehog-runner" % props.HedgehogVersion % Test,
"qa.hedgehog" %%% "hedgehog-sbt" % props.HedgehogVersion % Test,
)
)
lazy val extrasHedgehogCe3 = Def.setting("io.kevinlee" %%% "extras-hedgehog-ce3" % props.ExtrasVersion % Test)
}
}
def isScala3(scalaVersion: String): Boolean = scalaVersion.startsWith("3.")
// format: off
def prefixedProjectName(name: String) = s"${props.RepoName}${if (name.isEmpty) "" else s"-$name"}"
// format: on
////
def module(projectName: String, crossProject: CrossProject.Builder): CrossProject = {
val names = projectName.split("/")
val theProjectName = names.last
val location = names.toList
val prefixedName = prefixedProjectName(theProjectName)
commonModule(prefixedName, location, crossProject)
}
def testModule(projectName: String, crossProject: CrossProject.Builder): CrossProject = {
val names = projectName.split("/")
val theProjectName = names.last
val prefixedName = s"test-${prefixedProjectName(theProjectName)}"
val location = (names.init :+ prefixedName).toList
commonModule(prefixedName, location, crossProject)
}
def commonModule(prefixedName: String, path: List[String], crossProject: CrossProject.Builder): CrossProject = {
val modulePath = file(("modules" :: path).mkString("/"))
List(
modulePath / "shared" / "src" / "main" / "scala",
modulePath / "shared" / "src" / "test" / "scala",
).foreach(IO.createDirectory)
crossProject
.in(modulePath)
.settings(
name := prefixedName,
fork := true,
semanticdbEnabled := true,
scalafixConfig := (
if (scalaVersion.value.startsWith("3"))
((ThisBuild / baseDirectory).value / ".scalafix-scala3.conf").some
else
((ThisBuild / baseDirectory).value / ".scalafix-scala2.conf").some
),
scalacOptions ++= (if (isScala3(scalaVersion.value)) List("-no-indent", "-explain") else List("-Xsource:3")),
// scalacOptions ~= (ops => ops.filter(_ != "UTF-8")),
libraryDependencies ++= libs.tests.hedgehog.value,
wartremoverErrors ++= Warts.allBut(Wart.Any, Wart.Nothing, Wart.ImplicitConversion, Wart.ImplicitParameter),
Compile / console / scalacOptions :=
(console / scalacOptions)
.value
.filterNot(option => option.contains("wartremover") || option.contains("import")),
Test / console / scalacOptions :=
(console / scalacOptions)
.value
.filterNot(option => option.contains("wartremover") || option.contains("import")),
/* } WartRemover and scalacOptions */
licenses := props.licenses,
/* coverage { */
coverageHighlighting := (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 10)) | Some((2, 11)) =>
false
case _ =>
true
}),
/* } coverage */
)
}
lazy val jsSettingsForFuture: SettingsDefinition = List(
Test / fork := false,
scalaJSLinkerConfig ~= { _.withModuleKind(ModuleKind.CommonJSModule) },
scalacOptions ++= (if (scalaVersion.value.startsWith("3")) List.empty
else List("-Wconf:msg=dead code following this construct:s")),
Test / scalacOptions ++= (if (scalaVersion.value.startsWith("3")) List.empty
else List("-P:scalajs:nowarnGlobalExecutionContext")),
Test / compile / scalacOptions ++= (if (scalaVersion.value.startsWith("3")) List.empty
else List("-P:scalajs:nowarnGlobalExecutionContext")),
coverageEnabled := false,
)
lazy val nativeSettings: SettingsDefinition = List(
Test / fork := false,
coverageEnabled := false,
)