forked from com-lihaoyi/Ammonite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
312 lines (281 loc) · 9.14 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
import scalatex.ScalatexReadme
import sbtassembly.AssemblyPlugin.defaultShellScript
scalaVersion := "2.12.1"
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"
)
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.1",
organization := "com.lihaoyi",
version := _root_.ammonite.Constants.version,
libraryDependencies += "com.lihaoyi" %% "utest" % "0.4.4" % "test",
// Needed for acyclic to work...
libraryDependencies ++= {
if (scalaVersion.value startsWith "2.11.") Nil
else Seq(
"org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided"
)
},
testFrameworks := Seq(new TestFramework("utest.runner.Framework")),
scalacOptions += "-target:jvm-1.7",
autoCompilerPlugins := true,
addCompilerPlugin("com.lihaoyi" %% "acyclic" % "0.1.5"),
ivyScala := ivyScala.value map { _.copy(overrideScalaVersion = true) },
parallelExecution in Test := !scalaVersion.value.contains("2.10"),
(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.5" % "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.1",
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,
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 = assembly.value.getParentFile/"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,
crossVersion := CrossVersion.full,
name := "ammonite-util",
libraryDependencies ++= Seq(
"com.lihaoyi" %% "upickle" % "0.4.4",
"com.lihaoyi" %% "pprint" % "0.4.4"
)
)
lazy val ammRuntime = project
.in(file("amm/runtime"))
.dependsOn(ops, ammUtil)
.settings(
macroSettings,
sharedSettings,
crossVersion := CrossVersion.full,
name := "ammonite-runtime",
libraryDependencies ++= Seq(
"org.apache.ivy" % "ivy" % "2.4.0",
"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.2"
),
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.12"
)
)
/**
* 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,
name := "ammonite-shell",
(test in Test) <<= (test in Test).dependsOn(packageBin in Compile),
(run in Test) <<= (run in Test).dependsOn(packageBin in Compile),
(testOnly in Test) <<= (testOnly in Test).dependsOn(packageBin in Compile)
)
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:_*),
(run in Test) <<= (run in Test).dependsOn(integrationTasks:_*),
(testOnly in Test) <<= (testOnly in Test).dependsOn(integrationTasks:_*),
(console in Test) <<= (console in Test).dependsOn(integrationTasks:_*),
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(
"org.apache.sshd" % "sshd-core" % "0.14.0",
//-- 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.53" % "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.11.8",
libraryDependencies += "com.lihaoyi" %% "fansi" % "0.2.2",
(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)
),
(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)
}
}),
(unmanagedSources in Compile) += baseDirectory.value/".."/"project"/"Constants.scala"
)
lazy val published = project
.in(file("target/published"))
.aggregate(ops, shell, terminal, amm, sshd, ammUtil, ammRuntime, ammInterp, ammRepl)
.settings(dontPublishSettings)