-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathBuild.scala
281 lines (232 loc) · 10.9 KB
/
Build.scala
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
import sbt._
import Keys._
object ScadsBuild extends Build {
val buildVersion = "2.1.4-SNAPSHOT"
val defaultScalaVersion = "2.9.1"
val buildSettings = Defaults.defaultSettings ++ GhPages.ghpages.settings ++ sbtassembly.Plugin.assemblySettings ++ Seq(
organization := "edu.berkeley.cs",
scalaVersion := defaultScalaVersion,
version := buildVersion,
shellPrompt := ShellPrompt.buildShellPrompt,
resolvers := Seq(radlabRepo, localMaven),
GhPages.ghpages.gitRemoteRepo := "git@github.com:radlab/SCADS.git",
parallelExecution in Test := false,
libraryDependencies += "org.scala-tools.sxr" %% "sxr" % "0.2.8-SNAPSHOT" % "plugin",
ivyConfigurations += Configurations.CompilerPlugin,
/* HACK work around due to bugs in sbt compiler plugin handling code */
scalacOptions <++= (update, scalaSource in Compile) map {
(report, source) =>
val pluginClasspath = report matching configurationFilter(Configurations.CompilerPlugin.name)
pluginClasspath.map("-Xplugin:" + _.getAbsolutePath).toSeq :+ "-deprecation" :+ "-unchecked" :+ "-Yrepl-sync" :+ ("-P:sxr:base-directory:" + source.getAbsolutePath)
},
/* HACK to work around broken ~ in 0.11.0 */
watchTransitiveSources <<=
Defaults.inDependencies[Task[Seq[File]]](
watchSources.task, const(std.TaskExtra.constant(Nil)), aggregate = true, includeRoot = true) apply {
_.join.map(_.flatten)
})
val deploySettings = buildSettings ++ DeployConsole.deploySettings
addCompilerPlugin(avroPluginDep)
/* Artifact Repositories */
val localMaven = "Local Maven Repository" at "file://" + Path.userHome.absolutePath + "/.m2/repository"
val radlabRepo = "Radlab Repository" at "http://scads.knowsql.org/nexus/content/groups/public/"
/* Aggregator Project */
lazy val scads = Project("scads", file("."), settings = buildSettings) aggregate (config, avroPlugin, comm, deploylib, scalaEngine, piql, scadr, tpcw, modeling)
/* Avro Scala Compiler Plugin */
lazy val avroPlugin = Project("avro-plugin", file("avro"), settings = buildSettings ++ Seq(libraryDependencies ++= avroPluginDeps))
/* SCADS Core Projects */
lazy val config = Project(
"config",
file("config"),
settings = buildSettings ++ Seq(libraryDependencies ++= configDeps))
lazy val comm = Project(
"communication",
file("comm"),
settings = buildSettings ++ Seq(libraryDependencies ++= commDeps)
) dependsOn (config)
lazy val optional = Project(
"optional",
file("optional"),
settings = buildSettings ++ Seq(libraryDependencies ++= Seq(paranamer)))
lazy val deploylib = Project(
"deploylib",
file("deploylib"),
settings = deploySettings ++ Seq(
libraryDependencies ++= deploylibDeps)
) dependsOn (comm, optional)
lazy val scalaEngine = Project(
"scala-engine",
file("scalaengine"),
settings = deploySettings ++ Seq(
libraryDependencies ++= scalaEngineDeps)
) dependsOn (config, comm, deploylib)
lazy val piql = Project(
"piql", file("piql"),
settings = deploySettings ++ Seq(
libraryDependencies ++= useAvroPlugin,
initialCommands in console += (
"import edu.berkeley.cs.scads.piql._\n" +
"import edu.berkeley.cs.scads.piql.viz._\n"
))
) dependsOn (config, comm, scalaEngine)
lazy val perf = Project(
"perf",
file("perf"),
settings = deploySettings ++ Seq(
libraryDependencies ++= useAvroPlugin,
initialCommands in console += (
"import edu.berkeley.cs._\n" +
"import edu.berkeley.cs.avro._\n" +
"import edu.berkeley.cs.scads.comm._\n" +
"import edu.berkeley.cs.scads.storage._\n" +
"import edu.berkeley.cs.scads.perf._"))
) dependsOn (config, comm, scalaEngine, deploylib)
/* Other projects and experiments */
lazy val modeling = Project(
"modeling",
file("experiments/modeling"),
settings = deploySettings ++ Seq(
libraryDependencies ++= useAvroPlugin,
initialCommands in console += (
"import edu.berkeley.cs.scads.piql.modeling._\n" +
"import edu.berkeley.cs.scads.piql.modeling.Experiments._"))
) dependsOn (piql, perf, deploylib, scadr, tpcw)
lazy val scadr = Project(
"scadr",
file("piql/scadr"),
settings = deploySettings ++ Seq(
libraryDependencies ++= useAvroPlugin,
initialCommands in console += (
"import edu.berkeley.cs.scads.piql._\n" +
"import edu.berkeley.cs.scads.piql.viz._\n" +
"import edu.berkeley.cs.scads.piql.scadr._\n" +
"object testScadrClient extends ScadrClient(edu.berkeley.cs.scads.storage.TestScalaEngine.newScadsCluster(), new ParallelExecutor)"))
) dependsOn (piql % "compile;test->test", perf)
lazy val tpcw = Project(
"tpcw",
file("piql/tpcw"),
settings = deploySettings ++ Seq(libraryDependencies ++= useAvroPlugin)
) dependsOn (piql, perf)
lazy val mviews = Project(
"mviews",
file("piql/mviews"),
settings = deploySettings ++ Seq(
libraryDependencies ++= useAvroPlugin,
initialCommands in console += (
"import edu.berkeley.cs.scads.piql.mviews._\n" +
"import edu.berkeley.cs.scads.storage._\n" +
"import edu.berkeley.cs.scads.piql.exec._"
))
) dependsOn (piql, perf)
lazy val axer = Project(
"axer",
file("axer"),
settings = deploySettings ++ Seq(libraryDependencies ++= useAvroPlugin))
lazy val matheon = Project(
"matheon",
file("matheon"),
settings = deploySettings ++ Seq(libraryDependencies ++= useAvroPlugin)
) dependsOn (config, comm, scalaEngine)
/**
* Dependencies
*/
def configDeps = configgy +: testDeps //Note: must be a def to avoid null pointer exception
val configgy = "net.lag" % "configgy" % "2.0.0"
def testDeps = Seq(scalaTest, junit)
val scalaTest = "org.scalatest" %% "scalatest" % "1.6.1"
val junit = "junit" % "junit" % "4.7"
def avroPluginDeps = Seq(avroJava, avroIpc, scalaCompiler, configgy) ++ testDeps
val avroJava = "org.apache.avro" % "avro" % "1.6.0"
val avroIpc = "org.apache.avro" % "avro-ipc" % "1.6.0"
val scalaCompiler = "org.scala-lang" % "scala-compiler" % defaultScalaVersion
val avroPluginDep = "edu.berkeley.cs" %% "avro-plugin" % buildVersion % "plugin"
val avroPluginCompile = "edu.berkeley.cs" %% "avro-plugin" % buildVersion
val paranamer = "com.thoughtworks.paranamer" % "paranamer" % "2.0"
def useAvroPlugin = Seq(avroPluginDep, avroPluginCompile)
def commDeps = Seq(netty, zookeeper, commonsHttpClient, log4j, avroPluginDep, avroPluginCompile) ++ testDeps
val netty = "org.jboss.netty" % "netty" % "3.2.1.Final"
val log4j = "log4j" % "log4j" % "1.2.15"
val zookeeper = "org.apache.zookeeper" % "zookeeper" % "3.3.1"
def scalaEngineDeps = Seq(bdb, avroPluginDep, avroPluginCompile) ++ testDeps
val bdb = "com.sleepycat" % "je" % "4.0.71"
def deploylibDeps = Seq(mesos, protoBuff, staxApi, jaxbApi, json, awsSdk, ganymedSsh2, commonsLoggingApi, commonsHttpClient, jets3t, jetty, mysql, javaSysMon, avroPluginDep, avroPluginCompile)
val mesos = "org.apache" % "mesos" % "1.2"
val protoBuff = "com.google.protobuf" % "protobuf-java" % "2.3.0"
val staxApi = "javax.xml.stream" % "stax-api" % "1.0"
val jaxbApi = "javax.xml.bind" % "jaxb-api" % "2.1"
val json = "org.json" % "json" % "20090211"
val awsSdk = "com.amazonaws" % "aws-java-sdk" % "1.1.5"
val ganymedSsh2 = "ch.ethz.ganymed" % "ganymed-ssh2" % "build210"
val commonsLoggingApi = "commons-logging" % "commons-logging-api" % "1.1"
val commonsHttpClient = "commons-httpclient" % "commons-httpclient" % "3.0.1"
val jets3t = "net.java.dev.jets3t" % "jets3t" % "0.7.1"
val jetty = "org.mortbay.jetty" % "jetty" % "6.1.6"
val mysql = "mysql" % "mysql-connector-java" % "5.1.12"
val javaSysMon = "github.jezhumble" % "javasysmon" % "0.3.3"
def replDeps = Seq(lift, jetty6, servlet, sl4jConfiggy)
val lift = "net.liftweb" %% "lift-mapper" % "2.2-SNAPSHOT" % "compile"
val jetty6 = "org.mortbay.jetty" % "jetty" % "6.1.25" % "test"
val servlet = "javax.servlet" % "servlet-api" % "2.5" % "provided"
val sl4jConfiggy = "com.notnoop.logging" % "slf4j-configgy" % "0.0.1"
}
/**
* Mixin to create prompt of the form [current project]:[current git branch]>
*/
object ShellPrompt {
object devnull extends ProcessLogger {
def info(s: => String) {}
def error(s: => String) {}
def buffer[T](f: => T): T = f
}
val current = """\*\s+(\w+)""".r
def gitBranches = ("git branch --no-color" lines_! devnull mkString)
val buildShellPrompt = {
(state: State) => {
val currBranch = try current findFirstMatchIn gitBranches map (_ group (1)) getOrElse "-" catch {
case e => "noBranch"
}
val currProject = Project.extract(state).currentProject.id
"%s:%s> ".format(currProject, currBranch)
}
}
}
object DeployConsole extends BuildCommon {
import Classpaths._
import sbt.Project.Initialize
val packageDependencies = TaskKey[Seq[java.io.File]]("package-dependencies", "get package deps")
val deployConsole = TaskKey[Unit]("deploy-console", "scala console for deploying to EC2")
def findPackageDeps: Initialize[Task[Seq[java.io.File]]] =
(thisProjectRef, thisProject, settings) flatMap {
(projectRef: ProjectRef, project: ResolvedProject, data: Settings[Scope]) => {
def visit(p: ProjectRef): Seq[Task[java.io.File]] = {
val depProject = thisProject in p get data getOrElse sys.error("Invalid project: " + p)
val jarFile = (Keys.`package` in (p, ConfigKey("runtime"))).get(data).get
jarFile +: depProject.dependencies.map {
case ResolvedClasspathDependency(dep, confMapping) => dep
}.flatMap(visit).toList
}
visit(projectRef).join.map(_.toSet.toSeq)
}
}
val deploySettings = Seq(
packageDependencies <<= findPackageDeps,
deployConsole <<= (packageDependencies, fullClasspath in Runtime, compilers in console, scalacOptions in console, initialCommands in console, streams) map {
(deps: Seq[java.io.File], cp: Classpath, cs, options, initCmds, s) => {
val allJars = deps ++ cp.files.filter(_.getName endsWith "jar")
val cmds = Seq(
"import deploylib._",
"import deploylib.ec2._",
"import deploylib.mesos._",
"val allJars = " + allJars.map(f => "new java.io.File(\"%s\")".format(f.getCanonicalPath)).mkString("Seq(", ",", ")"),
"deploylib.mesos.MesosCluster.jarFiles = allJars",
"implicit val cluster = new Cluster()", // defaults to USEast1 unless overriden by AWS_DEFAULT_REGION env variable
"implicit def zooKeeperRoot = cluster.zooKeeperRoot",
"implicit def classSource = cluster.classSource",
"implicit def serviceScheduler = cluster.serviceScheduler"
).mkString("\n") + "\n" + initCmds
(new Console(cs.scalac))(Build.data(cp), options, cmds, "", s.log).foreach(msg => error(msg))
println()
}
}
)
}