forked from com-lihaoyi/Ammonite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
391 lines (351 loc) · 12 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
import scalatex.ScalatexReadme
scalaVersion := "2.12.3"
crossScalaVersions := Seq(
"2.10.4", "2.10.5", "2.10.6", "2.11.3",
"2.11.4", "2.11.5", "2.11.6", "2.11.7", "2.11.8", "2.11.9"
)
val dontPublishSettings = Seq(
publishArtifact := false,
publishTo := Some(Resolver.file("Unused transient repository", file("target/unusedrepo")))
)
dontPublishSettings
val macroSettings = Seq(
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided
) ++ (
if (!scalaVersion.value.startsWith("2.10.")) Nil
else Seq(
compilerPlugin("org.scalamacros" % s"paradise" % "2.0.1" cross CrossVersion.full),
"org.scalamacros" %% s"quasiquotes" % "2.0.1"
)
)
)
val sharedSettings = Seq(
scalaVersion := "2.12.3",
organization := "com.lihaoyi",
version := _root_.ammonite.Constants.version,
libraryDependencies += "com.lihaoyi" %% "utest" % "0.4.5" % Test,
// Needed for acyclic to work...
libraryDependencies ++= {
if (!scalaVersion.value.startsWith("2.10.")) Nil
else Seq(
"org.scala-lang" % "scala-compiler" % scalaVersion.value % Provided
)
},
testFrameworks := Seq(new TestFramework("utest.runner.Framework")),
scalacOptions += "-target:jvm-1.7",
scalacOptions += "-P:acyclic:force",
autoCompilerPlugins := true,
addCompilerPlugin("com.lihaoyi" %% "acyclic" % "0.1.7"),
ivyScala := ivyScala.value map { _.copy(overrideScalaVersion = true) },
parallelExecution in Test := false,
(unmanagedSources in Compile) += (baseDirectory in ThisBuild).value/"project"/"Constants.scala",
mappings in (Compile, packageSrc) += {
((baseDirectory in ThisBuild).value/".."/"project"/"Constants.scala") -> "Constants.scala"
},
libraryDependencies ++= Seq(
"com.lihaoyi" %% "acyclic" % "0.1.7" % Provided
) ,
publishTo := Some(
"releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2"
),
pomExtra :=
<url>https://github.com/lihaoyi/Ammonite</url>
<licenses>
<license>
<name>MIT license</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
</license>
</licenses>
<scm>
<url>git://github.com/lihaoyi/Ammonite.git</url>
<connection>scm:git://github.com/lihaoyi/Ammonite.git</connection>
</scm>
<developers>
<developer>
<id>lihaoyi</id>
<name>Li Haoyi</name>
<url>https://github.com/lihaoyi</url>
</developer>
</developers>
)
/**
* Concise, type-safe operating-system operations in Scala: filesystem,
* subprocesses, and other such things.
*/
lazy val ops = project
.settings(
sharedSettings,
libraryDependencies += "com.lihaoyi" %% "geny" % "0.1.2",
name := "ammonite-ops"
)
/**
* A standalone re-implementation of a composable readline-style REPL,
* without any behavior associated with it. Contains an echo-repl that
* can be run to test the REPL interactions
*/
lazy val terminal = project
.settings(
sharedSettings,
name := "ammonite-terminal",
libraryDependencies ++= Seq(
"com.lihaoyi" %% "sourcecode" % "0.1.3",
"com.lihaoyi" %% "fansi" % "0.2.3"
),
macroSettings
)
/**
* A better Scala REPL, which can be dropped in into any project or run
* standalone in a Scala project to provide a better interactive experience
* for Scala
*/
lazy val amm = project
.dependsOn(
terminal, ops,
ammUtil, ammRuntime, ammInterp, ammRepl
)
.settings(
macroSettings,
sharedSettings,
unmanagedSourceDirectories in Compile ++= {
if (Set("2.12", "2.11").contains(scalaBinaryVersion.value))
Seq(baseDirectory.value / "src" / "main" / "scala-2.11_2.12")
else
Seq()
},
// Aggregate source jars into both the amm/test:run as well as the assembly
// classpaths, so that the `source` macro can find their sources and
// highlight/display them.
// This includes them in the `amm/test:run` command
(fullClasspath in Test) ++= {
(updateClassifiers in Test).value
.configurations
.find(_.configuration == Test.name)
.get
.modules
.flatMap(_.artifacts)
.collect{case (a, f) if a.classifier == Some("sources") => f}
},
// This includes them in `amm/test:assembly
(fullClasspath in Runtime) ++= {
(updateClassifiers in Runtime).value
.configurations
.find(_.configuration == Runtime.name)
.get
.modules
.flatMap(_.artifacts)
.collect{case (a, f) if a.classifier == Some("sources") => f}
},
// This adds Ammonite's *own* source jars to the `amm/test:assembly`.
// We could, but don't, do it for `amm/test:run` because it's slow and
// annoying to run every time I just want to open a test REPL
fullClasspath in assembly ++= Seq(
(packageSrc in (ops, Compile)).value,
(packageSrc in (terminal, Compile)).value,
(packageSrc in (ammUtil, Compile)).value,
(packageSrc in (ammRuntime, Compile)).value,
(packageSrc in (ammInterp, Compile)).value,
(packageSrc in (ammRepl, Compile)).value,
(packageSrc in Compile).value
),
crossVersion := CrossVersion.full,
test in assembly := {},
name := "ammonite",
libraryDependencies ++= Seq(
"com.github.scopt" %% "scopt" % "3.5.0"
),
libraryDependencies ++= (
if (scalaVersion.value startsWith "2.10.") Nil
else Seq("com.chuusai" %% "shapeless" % "2.3.2" % Test)
),
javaOptions += "-Xmx4G",
assemblyOption in assembly := (assemblyOption in assembly).value.copy(
prependShellScript = Some(
// G1 Garbage Collector is awesome https://github.com/lihaoyi/Ammonite/issues/216
Seq("#!/usr/bin/env sh", """exec java -jar -Xmx500m -XX:+UseG1GC $JAVA_OPTS "$0" "$@"""")
)
),
assemblyJarName in assembly := s"${name.value}-${version.value}-${scalaVersion.value}",
assembly in Test := {
val dest = target.value/"amm"
IO.copyFile(assembly.value, dest)
import sys.process._
Seq("chmod", "+x", dest.getAbsolutePath).!
dest
}
)
lazy val ammUtil = project
.in(file("amm/util"))
.dependsOn(ops)
.settings(
macroSettings,
sharedSettings,
name := "ammonite-util",
libraryDependencies ++= Seq(
"com.lihaoyi" %% "upickle" % "0.4.4",
"com.lihaoyi" %% "pprint" % "0.5.2",
"com.lihaoyi" %% "fansi" % "0.2.4"
)
)
lazy val ammRuntime = project
.in(file("amm/runtime"))
.dependsOn(ops, ammUtil)
.settings(
macroSettings,
sharedSettings,
name := "ammonite-runtime",
libraryDependencies ++= Seq(
"io.get-coursier" %% "coursier" % "1.0.0-RC10",
"io.get-coursier" %% "coursier-cache" % "1.0.0-RC10",
"org.scalaj" %% "scalaj-http" % "2.3.0"
)
)
lazy val ammInterp = project
.in(file("amm/interp"))
.dependsOn(ops, ammUtil, ammRuntime)
.settings(
macroSettings,
sharedSettings,
crossVersion := CrossVersion.full,
name := "ammonite-compiler",
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-compiler" % scalaVersion.value,
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"com.lihaoyi" %% "scalaparse" % "0.4.3",
"org.javassist" % "javassist" % "3.21.0-GA"
),
unmanagedSourceDirectories in Compile ++= {
if (Set("2.10", "2.11").contains(scalaBinaryVersion.value))
Seq(baseDirectory.value / "src" / "main" / "scala-2.10_2.11")
else
Seq()
}
)
lazy val ammRepl = project
.in(file("amm/repl"))
.dependsOn(terminal, ammUtil, ammRuntime, ammInterp)
.settings(
macroSettings,
sharedSettings,
crossVersion := CrossVersion.full,
name := "ammonite-repl",
libraryDependencies ++= Seq(
"jline" % "jline" % "2.14.3",
"com.github.javaparser" % "javaparser-core" % "3.2.5"
),
unmanagedSourceDirectories in Compile ++= {
if (Set("2.12", "2.11").contains(scalaBinaryVersion.value))
Seq(baseDirectory.value / "src" / "main" / "scala-2.11_2.12")
else
Seq()
},
unmanagedSourceDirectories in Compile ++= {
if (Set("2.10", "2.11").contains(scalaBinaryVersion.value))
Seq(baseDirectory.value / "src" / "main" / "scala-2.10_2.11")
else
Seq()
}
)
/**
* Project that binds together [[ops]] and [[amm]], turning them into a
* credible systems shell that can be used to replace bash/zsh/etc. for
* common housekeeping tasks
*/
lazy val shell = project
.dependsOn(ops, amm % "compile->compile;test->test")
.settings(
sharedSettings,
macroSettings,
crossVersion := CrossVersion.full,
name := "ammonite-shell",
(test in Test) := (test in Test).dependsOn(packageBin in Compile).value,
(run in Test) := (run in Test).dependsOn(packageBin in Compile).evaluated,
(testOnly in Test) := (testOnly in Test).dependsOn(packageBin in Compile).evaluated
)
val integrationTasks = Seq(
assembly in amm,
packageBin in (shell, Compile)
)
lazy val integration = project
.dependsOn(ops)
.dependsOn(amm)
.settings(
sharedSettings,
(test in Test) := (test in Test).dependsOn(integrationTasks:_*).value,
(run in Test) := (run in Test).dependsOn(integrationTasks:_*).evaluated,
(testOnly in Test) := (testOnly in Test).dependsOn(integrationTasks:_*).evaluated,
(console in Test) := (console in Test).dependsOn(integrationTasks:_*).value,
parallelExecution in Test := false,
dontPublishSettings,
initialCommands in (Test, console) := "ammonite.integration.Main.main(null)"
)
/**
* REPL available via remote ssh access.
* Plug into any app environment for live hacking on a live application.
*/
lazy val sshd = project
.dependsOn(amm)
.settings(
sharedSettings,
crossVersion := CrossVersion.full,
name := "ammonite-sshd",
libraryDependencies ++= Seq(
// sshd-core 1.3.0 requires java8
"org.apache.sshd" % "sshd-core" % "1.2.0",
"org.bouncycastle" % "bcprov-jdk15on" % "1.56",
//-- test --//
// slf4j-nop makes sshd server use logger that writes into the void
"org.slf4j" % "slf4j-nop" % "1.7.12" % Test,
"com.jcraft" % "jsch" % "0.1.54" % Test,
"org.scalacheck" %% "scalacheck" % "1.12.6" % Test
)
)
lazy val readme = ScalatexReadme(
projectId = "readme",
wd = file(""),
url = "https://github.com/lihaoyi/ammonite/tree/master",
source = "Index"
).settings(
dontPublishSettings,
scalaVersion := "2.12.3",
libraryDependencies += "com.lihaoyi" %% "fansi" % "0.2.3",
(run in Compile) := (run in Compile).dependsOn(
assembly in (amm, Test),
packageBin in (shell, Compile),
doc in (ops, Compile),
doc in (terminal, Compile),
doc in (amm, Compile),
doc in (sshd, Compile),
doc in (shell, Compile)
).evaluated,
(run in Compile) := (run in Compile).dependsOn(Def.task{
val apiFolder = (target in Compile).value/"scalatex"/"api"
val copies = Seq(
(doc in (ops, Compile)).value -> "ops",
(doc in (terminal, Compile)).value -> "terminal",
(doc in (amm, Compile)).value -> "amm",
(doc in (sshd, Compile)).value -> "sshd",
(doc in (shell, Compile)).value -> "shell"
)
for ((folder, name) <- copies){
sbt.IO.copyDirectory(folder, apiFolder/name, overwrite = true)
}
}).evaluated,
(unmanagedSources in Compile) += baseDirectory.value/".."/"project"/"Constants.scala"
)
// Only modules down-stream of `ammInterp` need to be fully cross-built against
// minor versions, since `interp` depends on compiler internals. The modules
// upstream of `ammInterp` can be cross-built normally only against major versions
// of Scala
lazy val singleCrossBuilt = project
.in(file("target/singleCrossBuilt"))
.aggregate(ops, terminal, ammUtil, ammRuntime)
.settings(dontPublishSettings)
lazy val fullCrossBuilt = project
.in(file("target/fullCrossBuilt"))
.aggregate(shell, amm, sshd, ammInterp, ammRepl)
.settings(dontPublishSettings)
lazy val published = project
.in(file("target/published"))
.aggregate(fullCrossBuilt, singleCrossBuilt)
.settings(dontPublishSettings)