This repository was archived by the owner on Sep 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild.sbt
433 lines (381 loc) · 13.2 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
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
import scala.sys.process._
lazy val defaultIsabelleVersions = settingKey[Seq[Version]]("Default Isabelle versions")
defaultIsabelleVersions in ThisBuild := Seq()
lazy val standardSettings = Seq(
organization := "info.hupel",
scalaVersion := "2.12.6",
crossScalaVersions := Seq("2.11.12", "2.12.6"),
javacOptions += "-Xlint:unchecked",
homepage := Some(url("http://lars.hupel.info/libisabelle/")),
licenses := Seq(
"Apache-2.0" -> url("http://opensource.org/licenses/Apache-2.0"),
"BSD" -> url("http://opensource.org/licenses/BSD-3-Clause")
),
publishArtifact in Test := false,
pomIncludeRepository := { _ => false },
resolvers += Resolver.sonatypeRepo("public"),
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (version.value.endsWith("SNAPSHOT"))
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
},
pomExtra := (
<developers>
<developer>
<id>larsrh</id>
<name>Lars Hupel</name>
<url>http://lars.hupel.info</url>
</developer>
</developers>
),
credentials += Credentials(
Option(System.getProperty("build.publish.credentials")) map (new File(_)) getOrElse (Path.userHome / ".ivy2" / ".credentials")
),
isabelleVersions := {
isabelleVersions.?.value match {
case Some(Seq()) => (defaultIsabelleVersions in ThisBuild).value
case Some(ver) => ver
case None => Nil
}
},
autoAPIMappings := true
)
lazy val warningSettings = Seq(
scalacOptions ++= Seq(
"-deprecation",
"-feature",
"-encoding", "UTF-8",
"-unchecked",
"-Xlint",
"-Ypartial-unification",
"-Yno-adapted-args",
"-Ywarn-dead-code",
"-Ywarn-numeric-widen",
"-Ywarn-value-discard",
"-Xfatal-warnings"
),
scalacOptions in (Compile, doc) ~= (_.filterNot(_ == "-Xfatal-warnings")),
scalacOptions in (Compile, console) := Seq()
)
lazy val noPublishSettings = Seq(
publish := (()),
publishLocal := (()),
publishArtifact := false
)
lazy val macroSettings = Seq(
libraryDependencies ++= Seq(
scalaOrganization.value % "scala-compiler" % scalaVersion.value % "provided",
scalaOrganization.value % "scala-reflect" % scalaVersion.value % "provided",
compilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.patch)
)
)
lazy val loggingSettings = Seq(
libraryDependencies ++= Seq(
"io.rbricks" %% "scalog-backend" % "0.2.1",
"io.rbricks" %% "scalog-mdc" % "0.2.1",
// scalac requires this pseudo-transitive dependency of scalog to be present,
// even though we don't use its functionality here
// this seems to be an issue for Scala <= 2.11.x
"com.typesafe" % "config" % "1.3.4" % "provided"
)
)
lazy val apiBuildInfoKeys = Seq[BuildInfoKey](
version,
scalaVersion,
scalaBinaryVersion,
organization,
git.gitHeadCommit,
BuildInfoKey.map(defaultIsabelleVersions) { case (k, v) =>
(k, v collect { case Version.Stable(identifier) => identifier })
}
)
lazy val root = project.in(file("."))
.settings(standardSettings)
.settings(noPublishSettings)
.aggregate(
pideInterface, libisabelle, setup,
tests, docs, examples,
cli,
pideAggregate,
pidePackage,
workbench
)
lazy val tutDirectory = settingKey[String]("tut directory")
lazy val docs = project.in(file("modules/docs"))
.dependsOn(setup, pidePackage)
.settings(moduleName := "libisabelle-docs")
.settings(standardSettings)
.settings(macroSettings)
.settings(loggingSettings)
.enablePlugins(TutPlugin, ScalaUnidocPlugin, SiteScaladocPlugin, GhpagesPlugin)
.settings(
unidocProjectFilter in (ScalaUnidoc, unidoc) := inProjects(pideInterface, libisabelle, setup),
doc in Compile := (doc in ScalaUnidoc).value,
scalacOptions in (ScalaUnidoc, unidoc) ++= Seq(
"-doc-title", "libisabelle",
"-doc-version", version.value,
"-doc-source-url", s"https://github.com/larsrh/libisabelle/blob/${"git rev-parse HEAD" !!}€{FILE_PATH}.scala",
"-sourcepath", (baseDirectory in ThisBuild).value.getAbsolutePath,
"-Ypartial-unification"
),
target in unidoc in ScalaUnidoc := crossTarget.value / "api",
siteSubdirName in SiteScaladoc := "api/nightly",
ghpagesNoJekyll := false,
git.remoteRepo := "[email protected]:larsrh/libisabelle.git",
includeFilter in makeSite := "*.html" | "*.css" | "*.png" | "*.jpg" | "*.yml" | "*.md" | "Gemfile" | "config",
siteMappings += ((baseDirectory in ThisBuild).value / "README.md", "_includes/README.md"),
tutDirectory := "_tut",
// this seems to be required for scalog
libraryDependencies += "com.typesafe" % "config" % "1.3.4"
)
.settings(
addMappingsToSiteDir(tut, tutDirectory)
)
addCommandAlias("pushSite", "; docs/makeSite ; docs/ghpagesPushSite")
lazy val pideInterface = project.in(file("modules/pide-interface"))
.settings(moduleName := "pide-interface")
.settings(standardSettings)
.settings(warningSettings)
.enablePlugins(GitVersioning, BuildInfoPlugin)
.settings(
buildInfoKeys := apiBuildInfoKeys,
buildInfoPackage := "info.hupel.isabelle.api",
libraryDependencies ++= Seq(
"com.chuusai" %% "shapeless" % "2.3.3",
"io.monix" %% "monix-execution" % "3.0.0-RC1",
"org.log4s" %% "log4s" % "1.8.2",
// the dependencies below are not strictly necessary for pide-interface,
// but all non-generic PIDE implementations require them
"org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.1",
"org.tukaani" % "xz" % "1.8",
"com.jcraft" % "jsch" % "0.1.55",
"com.jcraft" % "jzlib" % "1.1.3",
"org.scala-lang" % "scala-compiler" % scalaVersion.value,
"org.xerial" % "sqlite-jdbc" % "3.28.0"
)
)
lazy val libisabelle = project.in(file("modules/libisabelle"))
.dependsOn(pideInterface)
.enablePlugins(LibisabellePlugin)
.settings(standardSettings)
.settings(warningSettings)
.settings(macroSettings)
.settings(
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-core" % "1.6.1",
"org.typelevel" %% "cats-free" % "1.6.1",
"com.lihaoyi" %% "scalatags" % "0.6.8",
"org.apache.commons" % "commons-lang3" % "3.9",
"info.hupel" % "classy" % "0.2.2",
"org.scala-lang.modules" %% "scala-java8-compat" % "0.9.0"
),
isabelleSessions in Compile := Seq(
"Protocol",
"HOL-Protocol"
)
)
lazy val setup = project.in(file("modules/setup"))
.dependsOn(libisabelle, pideInterface)
.enablePlugins(LibisabelleAssemblyPlugin)
.settings(moduleName := "libisabelle-setup")
.settings(standardSettings)
.settings(warningSettings)
.settings(
libraryDependencies ++= Seq(
"io.get-coursier" %% "coursier" % "1.0.3",
"io.get-coursier" %% "coursier-cache" % "1.0.3",
"org.apache.commons" % "commons-compress" % "1.18",
"org.eclipse.jgit" % "org.eclipse.jgit" % "5.3.2.201906051522-r",
"commons-io" % "commons-io" % "2.6"
)
)
// PIDE implementations
lazy val pideVersion = settingKey[Version]("PIDE version")
def pide(version: String) = Project(s"pide$version", file(s"modules/pide/$version"))
.dependsOn(pideInterface % "provided")
.settings(moduleName := s"pide-$version")
.settings(standardSettings)
.enablePlugins(GitVersioning, BuildInfoPlugin)
.settings(
buildInfoKeys := apiBuildInfoKeys,
pideVersion := Version.Stable(version),
buildInfoPackage := "info.hupel.isabelle.impl",
autoScalaLibrary := false,
assemblyJarName := s"${moduleName.value}-assembly.jar"
)
lazy val pide2017 = pide("2017")
lazy val pide2018 = pide("2018")
lazy val pide2019_RC4 = pide("2019-RC4")
lazy val pides = Seq(
pide2017,
pide2018,
pide2019_RC4
)
inThisBuild(pides.map { p =>
defaultIsabelleVersions += (pideVersion in p).value
})
lazy val pideAggregate = project.in(file("modules/pide-aggregate"))
.settings(noPublishSettings)
.settings(standardSettings)
.aggregate(pides.map(p => p: ProjectReference): _*)
def assemblyGenerator(p: Project) = Def.task {
val source = (assembly in p).value
val target = resourceManaged.value / source.getName
val log = streams.value.log
log.info(s"Copying assembly $source to $target ...")
IO.copyFile(source, target, preserveLastModified = true)
Seq(target)
}
lazy val pidePackage = project.in(file("modules/pide-package"))
.dependsOn(pideInterface)
.settings(moduleName := "pide-package")
.settings(standardSettings)
.settings(
pides.map { p =>
resourceGenerators in Compile += assemblyGenerator(p).taskValue
}
)
// Tests & CI
lazy val tests = project.in(file("tests"))
.settings(standardSettings)
.settings(noPublishSettings)
.aggregate(offlineTest, pureTest, holTest)
lazy val offlineTest = project.in(file("tests/offline"))
.dependsOn(setup, pidePackage)
.enablePlugins(LibisabellePlugin)
.settings(noPublishSettings)
.settings(standardSettings)
.settings(warningSettings)
.settings(loggingSettings)
.settings(
isabellePackage := "tests",
parallelExecution in Test := false,
libraryDependencies += "org.specs2" %% "specs2-scalacheck" % "4.5.1"
)
lazy val pureTest = project.in(file("tests/pure"))
.dependsOn(offlineTest)
.settings(noPublishSettings)
.settings(standardSettings)
.settings(warningSettings)
.settings(
parallelExecution in Test := false
)
lazy val holTest = project.in(file("tests/hol"))
.dependsOn(offlineTest)
.enablePlugins(LibisabellePlugin)
.settings(noPublishSettings)
.settings(standardSettings)
.settings(warningSettings)
.settings(
logBuffered in Test := false,
isabelleSessions in Test := Seq("HOL-Protocol-Test")
)
addCommandAlias("validateSlow", "; holTest/test ; test:isabelleBuild")
addCommandAlias("validateQuick", "; offlineTest/test ; pureTest/test")
// Standalone applications
lazy val cli = project.in(file("modules/cli"))
.dependsOn(setup, pidePackage)
.settings(moduleName := "isabellectl")
.settings(standardSettings)
.settings(warningSettings)
.settings(macroSettings)
.settings(loggingSettings)
.settings(
libraryDependencies += "com.github.alexarchambault" %% "case-app" % "1.1.3",
mainClass in Compile := Some("info.hupel.isabelle.cli.Main"),
assemblyJarName in assembly := s"isabellectl-assembly-${version.value}",
assemblyOption in assembly := (assemblyOption in assembly).value.copy(prependShellScript = Some(
Seq("#!/usr/bin/env sh", """exec java -jar "$0" "$@"""" + "\n")
))
)
.enablePlugins(LibisabellePlugin)
TaskKey[File]("script") := {
val executable = (assembly in cli).value.getCanonicalPath()
val script = (baseDirectory in ThisBuild).value / "isabellectl"
val text = s"""
|#!/usr/bin/env bash
|
|exec "$executable" "$$@"
|""".stripMargin.trim
streams.value.log.info(s"Writing script to $script ...")
IO.write(script, text)
script.setExecutable(true)
script
}
// Examples
lazy val examples = project.in(file("modules/examples"))
.dependsOn(setup, pidePackage)
.settings(noPublishSettings)
.settings(standardSettings)
.settings(warningSettings)
.settings(
// logback because Java
libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.2.3",
jsr223Scripts in Compile += Script(
"info.hupel.isabelle.examples.python",
"Hello_PIDE",
Language.Python,
Script.Literal("import hello_pide")
)
)
.enablePlugins(JSR223Plugin, JythonPlugin)
// Workbench
lazy val workbench = project.in(file("modules/workbench"))
.dependsOn(setup, pidePackage)
.settings(noPublishSettings)
.settings(standardSettings)
.settings(loggingSettings)
.settings(
initialCommands in console := """
import io.rbricks.scalog.{Level, LoggingBackend}
LoggingBackend.console("info.hupel" -> Level.Trace)
import info.hupel.isabelle._
import info.hupel.isabelle.api._
import info.hupel.isabelle.hol._
import info.hupel.isabelle.pure._
import info.hupel.isabelle.setup._
import scala.concurrent.duration.Duration
import scala.concurrent.Await
import monix.execution.Scheduler.Implicits.global
val setup = Setup.default(Version.Stable("2016-1"), false).right.get
val resources = Resources.dumpIsabelleResources().right.get
val config = Configuration.simple("HOL-Protocol")
val env = Await.result(setup.makeEnvironment(resources, Nil), Duration.Inf)
System.build(env, config)
val system = Await.result(System.create(env, config), Duration.Inf)
val main = Theory.get("Protocol_Main")
val ctxt = Context.initGlobal(main)
""",
cleanupCommands in console := """
system.dispose
""",
sourceGenerators in Compile += Def.task {
val contents = s"""object Test {
${(initialCommands in console).value}
${(cleanupCommands in console).value}
}"""
val file = (sourceManaged in Test).value / "test.scala"
IO.write(file, contents)
Seq(file)
}.taskValue
)
// Release stuff
import ReleaseTransformations._
releaseVcsSign := true
releaseCrossBuild := true
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
publishArtifacts,
setNextVersion,
commitNextVersion,
releaseStepCommand("sonatypeRelease")
)
// Miscellaneous
cancelable in Global := true