forked from com-lihaoyi/Ammonite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
171 lines (154 loc) · 5.62 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
import scalatex.ScalatexReadme
import sbtassembly.AssemblyPlugin.defaultShellScript
scalaVersion := "2.11.6"
crossScalaVersions := Seq(
"2.10.3", "2.10.4", "2.10.5", "2.11.3", "2.11.4", "2.11.5", "2.11.6", "2.11.7"
)
publishArtifact := false
publishTo := Some(Resolver.file("Unused transient repository", file("target/unusedrepo")))
val sharedSettings = Seq(
scalaVersion := "2.11.7",
organization := "com.lihaoyi",
version := _root_.ammonite.Constants.version,
libraryDependencies += "com.lihaoyi" %% "utest" % "0.3.0" % "test",
testFrameworks += new TestFramework("utest.runner.Framework"),
scalacOptions += "-target:jvm-1.7",
autoCompilerPlugins := true,
addCompilerPlugin("com.lihaoyi" %% "acyclic" % "0.1.2"),
parallelExecution in Test := !scalaVersion.value.contains("2.10"),
libraryDependencies ++= Seq(
"com.lihaoyi" %% "acyclic" % "0.1.2" % "provided",
"org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided"
) ++ (
if (scalaVersion.value startsWith "2.11.") Nil
else Seq(
compilerPlugin("org.scalamacros" % s"paradise" % "2.0.1" cross CrossVersion.full),
"org.scalamacros" %% s"quasiquotes" % "2.0.1"
)
),
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:_*)
.settings(
name := "ammonite-ops",
libraryDependencies += "com.lihaoyi" %% "pprint" % "0.3.4"
)
lazy val tools = project
.dependsOn(ops)
.settings(sharedSettings:_*)
.settings(
name := "ammonite-tools",
libraryDependencies += "com.lihaoyi" %% "pprint" % "0.3.4"
)
/**
* 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:_*)
.settings(
name := "ammonite-terminal"
)
/**
* 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 repl = project
.dependsOn(terminal, ops)
.settings(sharedSettings:_*)
.settings(
crossVersion := CrossVersion.full,
test in assembly := {},
name := "ammonite-repl",
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-compiler" % scalaVersion.value,
"jline" % "jline" % "2.12",
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.apache.ivy" % "ivy" % "2.4.0",
"com.lihaoyi" %% "scalaparse" % "0.2.1",
"com.lihaoyi" %% "upickle" % "0.3.5",
"com.lihaoyi" %% "pprint" % "0.3.5",
"com.github.scopt" %% "scopt" % "3.3.0"
),
libraryDependencies ++= (
if (scalaVersion.value startsWith "2.10.") Nil
else Seq("com.chuusai" %% "shapeless" % "2.1.0" % "test")
),
(unmanagedSources in Compile) += baseDirectory.value/".."/"project"/"Constants.scala",
javaOptions += "-Xmx4G",
assemblyOption in assembly := (assemblyOption in assembly).value.copy(
prependShellScript = Some(defaultShellScript)
),
assemblyJarName in assembly := s"${name.value}-${version.value}-${scalaVersion.value}",
sourceGenerators in Compile <+= sourceManaged in Compile map { dir =>
val file = dir/"ammonite"/"pprint"/"PPrintGen.scala"
val typeGen = for(i <- 2 to 22) yield {
val ts = (1 to i).map("T" + _).mkString(", ")
val tsBounded = (1 to i).map("T" + _ + ": Type").mkString(", ")
val tsGet = (1 to i).map("get[T" + _ + "](cfg)").mkString(" + \", \" + ")
s"""
implicit def F${i}TPrint[$tsBounded, R: Type] = make[($ts) => R](cfg =>
"(" + $tsGet + ") => " + get[R](cfg)
)
implicit def T${i}TPrint[$tsBounded] = make[($ts)](cfg =>
"(" + $tsGet + ")"
)
"""
}
val output = s"""
package ammonite.repl.frontend
trait TPrintGen[Type[_], Cfg]{
def make[T](f: Cfg => String): Type[T]
def get[T: Type](cfg: Cfg): String
implicit def F0TPrint[R: Type] = make[() => R](cfg => "() => " + get[R](cfg))
implicit def F1TPrint[T1: Type, R: Type] = make[T1 => R](cfg => get[T1](cfg) + " => " + get[R](cfg))
${typeGen.mkString("\n")}
}
""".stripMargin
IO.write(file, output)
Seq(file)
}
// fork in (Test, testOnly) := true
)
lazy val readme = ScalatexReadme(
projectId = "readme",
wd = file(""),
url = "https://github.com/lihaoyi/ammonite/tree/master",
source = "Index"
).settings(
publishArtifact := false,
publishTo := Some(Resolver.file("Unused transient repository", file("target/unusedrepo"))),
(unmanagedSources in Compile) += baseDirectory.value/".."/"project"/"Constants.scala"
)
lazy val modules = project.aggregate(
ops, tools, terminal, repl
).settings(
publishArtifact := false,
publishTo := Some(Resolver.file("Unused transient repository", file("target/unusedrepo")))
)