-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sbt
211 lines (187 loc) · 6.17 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
import Dependencies.*
/* Core settings */
ThisBuild / scalaVersion := "3.5.2"
val groupId = "com.github.gerlichlab"
val projectName = "gerlib"
val rootPkg = s"at.ac.oeaw.imba.gerlich.$projectName"
val gitHubOwner = "gerlichlab"
val gitPubUrl = s"https://github.com/$gitHubOwner/$projectName.git"
val primaryJavaVersion = "11"
val primaryOs = "ubuntu-latest"
val isPrimaryOsAndPrimaryJavaTest = s"runner.os == '$primaryOs' && runner.java-version == '$primaryJavaVersion'"
// Needed for ZARR (jzarr) (?)
ThisBuild / resolvers += "Unidata UCAR" at "https://artifacts.unidata.ucar.edu/content/repositories/unidata-releases/"
/* sbt-github-actions settings */
ThisBuild / githubWorkflowOSes := Seq(primaryOs, "ubuntu-20.04", "macos-latest")
ThisBuild / githubWorkflowTargetBranches := Seq("main")
ThisBuild / githubWorkflowPublishTargetBranches := Seq()
ThisBuild / githubWorkflowJavaVersions := Seq(primaryJavaVersion, "17", "19", "21").map(JavaSpec.temurin)
ThisBuild / githubWorkflowBuildPreamble ++= Seq(
// Account for the absence of sbt in newer versions of the setup-java GitHub Action.
WorkflowStep.Run(commands = List("brew install sbt"), cond = Some("contains(runner.os, 'macos')")),
/* Add linting and formatting checks, but only limit to a single platform + Java combo. */
WorkflowStep.Sbt(
List("scalafmtCheckAll"),
name = Some("Check formatting with scalafmt"),
cond = Some(isPrimaryOsAndPrimaryJavaTest),
),
WorkflowStep.Sbt(
List("scalafixAll --check"),
name = Some("Lint with scalafix"),
cond = Some(isPrimaryOsAndPrimaryJavaTest),
),
)
ThisBuild / assemblyMergeStrategy := {
case "module-info.class" => MergeStrategy.discard
case x =>
val oldStrategy = (ThisBuild / assemblyMergeStrategy).value
oldStrategy(x)
}
ThisBuild / testOptions += Tests.Argument("-oF") // full stack traces
lazy val root = project
.in(file("."))
.aggregate(cell, geometry, graph, imaging, io, json, numeric, pan, roi, testing, zarr)
.enablePlugins(BuildInfoPlugin)
.settings(commonSettings)
.settings(noPublishSettings)
.settings(
name := projectName,
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
buildInfoPackage := s"$rootPkg.internal"
)
lazy val cell = defineModule("cell")(project)
.dependsOn(numeric)
lazy val geometry = defineModule("geometry")(project)
.dependsOn(numeric)
lazy val graph = defineModule("graph")(project)
.settings(
libraryDependencies ++= Seq(
scalaGraphCore,
catsLaws % Test,
disciplineScalatest % Test,
),
)
lazy val io = defineModule("io")(project)
.dependsOn(cell, geometry, imaging, pan, roi)
.settings(
libraryDependencies ++= Seq(
fs2Csv,
fs2IO,
os,
)
)
lazy val imaging = defineModule("imaging")(project)
.dependsOn(json, numeric)
.settings(
libraryDependencies ++= Seq(
iron % Test,
ironScalacheck % Test,
uJson,
uPickle,
)
)
lazy val json = defineModule("json")(project)
.dependsOn(geometry, numeric)
.settings(
libraryDependencies ++= Seq(
uJson,
uPickle,
)
)
lazy val numeric = defineModule("numeric")(project)
.dependsOn(pan)
.settings(
libraryDependencies ++= Seq(
iron,
ironCats,
ironScalacheck % Test,
)
)
// "pan"-subproject types and functions
lazy val pan = defineModule("pan")(project)
.settings(
libraryDependencies ++= Seq(
catsLaws % Test,
disciplineScalatest % Test,
iron,
ironScalacheck % Test,
)
)
lazy val roi = defineModule("roi")(project)
.dependsOn(geometry, numeric, zarr)
lazy val testing = defineModule("testing", false)(project)
.dependsOn(geometry, imaging, io, numeric)
.settings(libraryDependencies ++= Seq(
ironScalacheck,
scalacheck,
scalatest % Test,
scalatestScalacheck % Test,
))
lazy val zarr = defineModule("zarr")(project)
.dependsOn(imaging, numeric)
.settings(libraryDependencies ++= Seq(jzarr))
lazy val commonSettings = Def.settings(
compileSettings,
metadataSettings,
)
// For subprojects that shouldn't be published (e.g., root)
lazy val noPublishSettings = Def.settings(
publish / skip := true
)
lazy val compileSettings = Def.settings(
scalacOptions ++= Seq(
"-deprecation",
"-encoding",
"utf8",
"-feature",
"-language:existentials",
"-explain",
// https://contributors.scala-lang.org/t/for-comprehension-requires-withfilter-to-destructure-tuples/5953
"-source:future", // for tuples in for comprehension; see above link
"-unchecked",
"-Wunused:all", // for scalafix RemoveUnused: https://scalacenter.github.io/scalafix/docs/rules/RemoveUnused.html
),
Compile / console / scalacOptions -= "-Ywarn-unused:imports",
Test / console / scalacOptions := (Compile / console / scalacOptions).value,
)
lazy val versionNumber = "0.3.2"
lazy val metadataSettings = Def.settings(
name := projectName,
description := "Gerlich lab programming utilities, especially for data from imaging or sequencing",
version := versionNumber,
isSnapshot := versionNumber.endsWith("SNAPSHOT"), // Allow publish overwrites: https://github.com/sbt/sbt/issues/1156#issuecomment-43512022
organization := groupId,
organizationName := "Gerlich Group, IMBA, ÖAW",
homepage := Some(url(s"https://github.com/$gitHubOwner/$projectName")),
startYear := Some(2015),
licenses := Seq("MIT" -> url("http://opensource.org/licenses/MIT")),
scmInfo := Some(ScmInfo(homepage.value.get, s"scm:git:$gitPubUrl", None)),
developers := List(
Developer(
id = "vreuter",
name = "Vince Reuter",
email = "",
url("https://github.com/vreuter")
)
)
)
lazy val testDependencies = Seq(
scalacheck,
scalactic,
scalatest,
scalatestScalacheck,
)
// The subprojects/modules share similar structure, so DRY.
def defineModule(name: String, addTestDeps: Boolean = true): Project => Project =
_.in(file(s"modules/$name"))
.settings(commonSettings)
.settings(moduleName := s"$projectName-$name")
.settings(
libraryDependencies ++= Seq(
catsCore,
kittens,
mouse,
) ++ (
if (addTestDeps) testDependencies.map(_ % Test) else Seq()
),
)