-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.sbt
414 lines (386 loc) · 17.1 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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
import microsites._
import ReleaseTransformations._
import com.typesafe.tools.mima.plugin.MimaPlugin.mimaDefaultSettings
inThisBuild(List(
organization := "edu.monash",
scalaVersion := "2.12.6",
crossScalaVersions := Seq("2.11.12", "2.12.6")
))
addCommandAlias(
"gitSnapshots",
";set version in ThisBuild := git.gitDescribedVersion.value.get + \"-SNAPSHOT\"")
/**
* Common dep versions
*/
lazy val imglib2Version = "5.2.0"
lazy val imglib2RTVersion = "2.0.0"
lazy val scifioVersion = "0.36.0"
lazy val scifioOMEVersion = "0.14.3"
lazy val bdvCoreVersion = "5.0.0"
lazy val imagejVersion = "2.0.0-rc-66"
lazy val ijLegacyVersion = "0.30.0"
lazy val ijScalaVersion = "0.2.1"
/**
* Settings
*/
val disabledReplOptions = Set(
"-Ywarn-unused-import",
"-Ywarn-unused:import",
"-Xfatal-warnings"
)
lazy val buildSettings = Seq(
scalacOptions ++= orgScalacOptions(scalaOrganization.value),
libraryDependencies ++= scalaVersionDeps(scalaVersion.value)
)
lazy val commonSettings = List(
licenses ++= Seq(
("MIT", url("http://opensource.org/licenses/MIT"))
),
scalacOptions ++= Seq(
"-deprecation", // Emit warning and location for usages of deprecated APIs.
"-encoding", "utf-8", // Specify character encoding used by source files.
"-explaintypes", // Explain type errors in more detail.
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
"-language:existentials", // Existential types (besides wildcard types) can be written and inferred
"-language:experimental.macros", // Allow macro definition (besides implementation and application)
"-language:higherKinds", // Allow higher-kinded types
"-language:implicitConversions", // Allow definition of implicit functions called views
"-unchecked", // Enable additional warnings where generated code depends on assumptions.
"-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access.
"-Xfatal-warnings", // Fail the compilation if there are any warnings.
"-Xfuture", // Turn on future language features.
"-Xlint:adapted-args", // Warn if an argument list is modified to match the receiver.
"-Xlint:by-name-right-associative", // By-name parameter of right associative operator.
"-Xlint:delayedinit-select", // Selecting member of DelayedInit.
"-Xlint:doc-detached", // A Scaladoc comment appears to be detached from its element.
"-Xlint:inaccessible", // Warn about inaccessible types in method signatures.
"-Xlint:infer-any", // Warn when a type argument is inferred to be `Any`.
"-Xlint:missing-interpolator", // A string literal appears to be missing an interpolator id.
"-Xlint:nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'.
"-Xlint:nullary-unit", // Warn when nullary methods return Unit.
"-Xlint:option-implicit", // Option.apply used implicit view.
"-Xlint:package-object-classes", // Class or object defined in package object.
"-Xlint:poly-implicit-overload", // Parameterized overloaded implicit methods are not visible as view bounds.
"-Xlint:private-shadow", // A private field (or class parameter) shadows a superclass field.
"-Xlint:stars-align", // Pattern sequence wildcard must align with sequence component.
"-Xlint:type-parameter-shadow", // A local type parameter shadows a type already in scope.
"-Xlint:unsound-match", // Pattern match may not be typesafe.
"-Yno-adapted-args", // Do not adapt an argument list (either by inserting () or creating a tuple) to match the receiver.
"-Ypartial-unification", // Enable partial unification in type constructor inference
"-Ywarn-dead-code", // Warn when dead code is identified.
"-Ywarn-inaccessible", // Warn about inaccessible types in method signatures.
"-Ywarn-infer-any", // Warn when a type argument is inferred to be `Any`.
"-Ywarn-nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'.
"-Ywarn-nullary-unit", // Warn when nullary methods return Unit.
"-Ywarn-numeric-widen", // Warn when numerics are widened.
"-Ywarn-value-discard" // Warn when non-Unit expression results are unused.
) ++ scalaVersionFlags(scalaVersion.value),
resolvers ++= Seq(
"imagej.public" at "http://maven.imagej.net/content/groups/public"
),
addCompilerPlugin(
"org.spire-math" % "kind-projector" % "0.9.4" cross CrossVersion.binary
),
scalacOptions in (Compile, console) := (scalacOptions in (Compile, console)).value.filterNot(disabledReplOptions.contains(_)),
scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value
)
lazy val coreApiSettings = List(
wartremoverWarnings in (Compile, compile) ++= Warts.unsafe
)
lazy val publishSettings = List(
publishTo := Some(Resolver.file("file", new File(Path.userHome.absolutePath+"/.m2/repository"))),
// publishTo := {
// val nexus = "https://oss.sonatype.org/"
// if (isSnapshot.value)
// Some("snapshots" at nexus + "content/repositories/snapshots")
// else
// Some("releases" at nexus + "service/local/staging/deploy/maven2")
// },
publishMavenStyle := true,
publishArtifact in Test := false,
useGpg := true,
homepage := Some(url("https://github.com/monash-merc/llsm")),
pomIncludeRepository := Function.const(false),
pomExtra := (
<scm>
<url>[email protected]:monash-merc/llsm.git</url>
<connection>scm:git:[email protected]:monash-merc/llsm.git</connection>
</scm>
<developers>
<developer>
<id>keithschulze</id>
<name>Keith Schulze</name>
<url>https://platforms.monash.edu/mmi/</url>
</developer>
</developers>
),
releaseCrossBuild := true,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
releaseProcess := List[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
releaseStepCommand("package"),
setReleaseVersion,
commitReleaseVersion,
tagRelease,
releaseStepCommand("publishSigned"),
setNextVersion,
commitNextVersion,
// ReleaseStep(action = Command.process("sonatypeReleaseAll", _)),
pushChanges
)
)
lazy val noPublishSettings = List(
publish := {},
publishLocal := {},
publishArtifact := false
)
lazy val scoverageSettings = Seq(
coverageMinimum := 60,
coverageFailOnMinimum := false
)
lazy val llsmSettings = buildSettings ++ commonSettings ++ publishSettings ++ scoverageSettings
lazy val docMappingsApiDir =
settingKey[String]("Subdirectory in site target directory for API docs")
lazy val docSettings = Seq(
micrositeName := "LLSM",
micrositeDescription := "Lattice Light-Sheet Microscopy",
micrositeAuthor := "Keith Schulze",
micrositeHighlightTheme := "atom-one-light",
micrositeBaseUrl := "llsm",
micrositeDocumentationUrl := "/llsm/api/",
micrositeGithubOwner := "monash-merc",
micrositeGithubRepo := "llsm",
micrositePalette := Map(
"brand-primary" -> "#009FD8",
"brand-secondary" -> "#006CAB",
"brand-tertiary" -> "#004D7B",
"gray-dark" -> "#231F20",
"gray" -> "#423F40",
"gray-light" -> "#939598",
"gray-lighter" -> "#F7F8F8",
"white-color" -> "#FFFFFF"
),
autoAPIMappings := true,
unidocProjectFilter in (ScalaUnidoc, unidoc) := inProjects(core, api),
docMappingsApiDir := "api",
addMappingsToSiteDir(mappings in (ScalaUnidoc, packageDoc),
docMappingsApiDir),
git.remoteRepo := "[email protected]:monash-merc/llsm.git",
ghpagesNoJekyll := false,
fork in tut := true,
fork in (ScalaUnidoc, unidoc) := true,
scalacOptions in (ScalaUnidoc, unidoc) ++= Seq(
"-doc-source-url",
"https://github.com/monash-merc/llsm/tree/master€{FILE_PATH}.scala",
"-sourcepath",
baseDirectory.in(LocalRootProject).value.getAbsolutePath,
"-diagrams"
),
includeFilter in makeSite := "*.html" | "*.css" | "*.png" | "*.jpg" | "*.gif" | "*.js" | "*.swf" | "*.yml" | "*.md"
)
disablePlugins(AssemblyPlugin)
//Projects
lazy val docs = project
.in(file("docs"))
.disablePlugins(AssemblyPlugin)
.enablePlugins(ScalaUnidocPlugin)
.enablePlugins(MicrositesPlugin)
.settings(moduleName := "llsm-docs")
.settings(llsmSettings)
.settings(noPublishSettings)
.settings(docSettings)
.settings(
scalacOptions in Tut ~= (_.filterNot(
Set(
"-Ywarn-unused-import",
"-Ywarn-dead-code",
"-Ywarn-unused:imports"
)
)),
libraryDependencies ++= Seq(
"net.imglib2" % "imglib2" % imglib2Version % "tut",
"net.imglib2" % "imglib2-algorithm" % "0.9.0" % "tut",
"net.imglib2" % "imglib2-realtransform" % imglib2RTVersion % "tut",
"io.scif" % "scifio" % scifioVersion % "tut",
"io.scif" % "scifio-ome-xml" % scifioOMEVersion % "tut",
"sc.fiji" % "bigdataviewer-core" % bdvCoreVersion % "tut"
)
)
.dependsOn(core, api)
lazy val llsm = project
.in(file("."))
.disablePlugins(AssemblyPlugin)
.settings(llsmSettings)
.settings(noPublishSettings)
.aggregate(core, api, ij, cli, tests, docs)
.dependsOn(core,
api,
ij,
cli,
tests % "compile;test-internal -> test",
benchmark % "compile-internal;test-internal -> test")
lazy val core = project
.in(file("core"))
.disablePlugins(AssemblyPlugin)
.settings(moduleName := "llsm-core")
.settings(llsmSettings)
.settings(coreApiSettings)
.settings(
exportJars := true,
libraryDependencies ++= Seq(
"net.imglib2" % "imglib2" % imglib2Version % "provided",
"net.imglib2" % "imglib2-algorithm" % "0.9.0" % "provided",
"net.imglib2" % "imglib2-realtransform" % imglib2RTVersion % "provided",
"io.scif" % "scifio" % scifioVersion % "provided"
) ++ coreVersionDeps(scalaVersion.value)
)
lazy val api = project
.in(file("api"))
.disablePlugins(AssemblyPlugin)
.dependsOn(core)
.settings(moduleName := "llsm-api")
.settings(llsmSettings)
.settings(coreApiSettings)
.settings(
exportJars := true,
libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-xml" % "1.1.0",
"org.typelevel" %% "cats-free" % "1.1.0",
"net.imglib2" % "imglib2" % imglib2Version % "provided",
"net.imglib2" % "imglib2-realtransform" % imglib2RTVersion % "provided",
"io.scif" % "scifio" % scifioVersion % "provided",
"io.scif" % "scifio-ome-xml" % scifioOMEVersion % "provided",
"sc.fiji" % "bigdataviewer-core" % bdvCoreVersion % "provided"
)
)
lazy val cli = project
.in(file("cli"))
.disablePlugins(AssemblyPlugin)
.enablePlugins(JavaAppPackaging)
.dependsOn(core, api)
.settings(moduleName := "llsm-cli")
.settings(llsmSettings)
.settings(noPublishSettings)
.settings(
libraryDependencies ++= Seq(
"com.github.scopt" %% "scopt" % "3.7.0",
"net.imglib2" % "imglib2" % imglib2Version,
"net.imglib2" % "imglib2-realtransform" % imglib2RTVersion,
"io.scif" % "scifio" % scifioVersion,
"io.scif" % "scifio-ome-xml" % scifioOMEVersion,
"sc.fiji" % "bigdataviewer-core" % bdvCoreVersion
),
name := "llsmc",
mainClass in Compile := Some("llsm.cli.LLSMC")
)
lazy val ij = project
.in(file("ij"))
.dependsOn(core, api)
.settings(moduleName := "llsm-ij")
.settings(llsmSettings)
.settings(noPublishSettings)
.settings(
libraryDependencies ++= Seq(
"io.scif" % "scifio-ome-xml" % scifioOMEVersion % "provided",
"net.imagej" % "imagej" % imagejVersion % "provided",
"net.imagej" % "imagej-legacy" % ijLegacyVersion % "provided",
"org.scijava" % "scripting-scala" % ijScalaVersion % "provided",
"net.imglib2" % "imglib2" % imglib2Version % "provided",
"net.imglib2" % "imglib2-cache" % "1.0.0-beta-9" % "provided",
"net.imglib2" % "imglib2-realtransform" % imglib2RTVersion % "provided",
"net.imglib2" % "imglib2-ui" % "2.0.0" % "provided",
"sc.fiji" % "bigdataviewer-core" % bdvCoreVersion % "provided",
"sc.fiji" % "bigdataviewer-vistools" % "1.0.0-beta-11" % "provided"
),
scalacOptions ~= (_ filterNot(_ == "-Xcheckinit")), // disable checkinit because ImageJ does a lot of runtime injection
mainClass in (Compile, run) := Some("net.imagej.Main"),
fork in run := true,
javaOptions ++= Seq("-Xmx12G"),//, "-Dscijava.log.level=debug"),
test in assembly := {},
assemblyJarName in assembly := s"llsm-ij-${version.value}.jar",
assemblyOption in assembly := (assemblyOption in assembly).value
.copy(includeScala = false, cacheOutput = false),
run in Compile := Defaults.runTask(fullClasspath in Compile,
mainClass in (Compile, run),
runner in (Compile, run)).evaluated
)
lazy val tests = project
.in(file("tests"))
.disablePlugins(AssemblyPlugin)
.dependsOn(core, api)
.settings(moduleName := "llsm-tests")
.settings(llsmSettings)
.settings(coreApiSettings)
.settings(noPublishSettings: _*)
.settings(
libraryDependencies ++= Seq(
"org.scalacheck" %% "scalacheck" % "1.14.0",
"org.scalatest" %% "scalatest" % "3.0.5",
"net.imglib2" % "imglib2" % imglib2Version,
"net.imglib2" % "imglib2-realtransform" % imglib2RTVersion,
"io.scif" % "scifio" % scifioVersion,
"io.scif" % "scifio-ome-xml" % scifioOMEVersion,
"sc.fiji" % "bigdataviewer-core" % bdvCoreVersion
)
)
lazy val benchmark = project
.in(file("benchmark"))
.disablePlugins(AssemblyPlugin)
.enablePlugins(JmhPlugin)
.settings(llsmSettings: _*)
.settings(noPublishSettings: _*)
.dependsOn(core, api)
.settings(
libraryDependencies ++= Seq(
"net.imglib2" % "imglib2" % imglib2Version,
"net.imglib2" % "imglib2-realtransform" % imglib2RTVersion,
"net.imagej" % "imagej" % imagejVersion,
"io.scif" % "scifio" % scifioVersion,
"io.scif" % "scifio-ome-xml" % scifioOMEVersion,
"sc.fiji" % "bigdataviewer-core" % bdvCoreVersion,
"io.monix" %% "monix" % "3.0.0-RC1",
)
)
def scalaVersionFlags(version: String): List[String] =
CrossVersion.partialVersion(version) match {
case Some((2, 11)) => List(
"-Ywarn-unused-import"
)
case _ => List(
"-Ywarn-extra-implicit", // Warn when more than one implicit parameter section is defined.
"-Ywarn-unused:implicits", // Warn if an implicit parameter is unused.
"-Ywarn-unused:imports", // Warn if an import selector is not referenced.
"-Ywarn-unused:locals", // Warn if a local definition is unused.
"-Ywarn-unused:params", // Warn if a value parameter is unused.
"-Ywarn-unused:patvars", // Warn if a variable bound in a pattern is unused.
"-Ywarn-unused:privates", // Warn if a private member is unused.
"-Xlint:constant")
}
def orgScalacOptions(version: String): List[String] =
version match {
case "org.typelevel" => List(
"-Yinduction-heuristics", // speeds up the compilation of inductive implicit resolution
"-Ykind-polymorphism", // type and method definitions with type parameters of arbitrary kinds
"-Yliteral-types", // literals can appear in type position
"-Xstrict-patmat-analysis", // more accurate reporting of failures of match exhaustivity
"-Xlint:strict-unsealed-patmat" // warn on inexhaustive matches against unsealed traits
)
case _ => List.empty
}
def scalaVersionDeps(version: String): List[ModuleID] = {
CrossVersion.partialVersion(version) match {
case Some((2, 11)) => List.empty
case Some((2, 12)) => List.empty
case _ => List.empty
}
}
// Cats required to support Right-biased Either in scala 2.11
def coreVersionDeps(version: String): List[ModuleID] =
CrossVersion.partialVersion(version) match {
case Some((2, 11)) =>
List("org.typelevel" %% "cats-core" % "1.1.0")
case Some((2, 12)) => List.empty
case _ => List.empty
}