-
Notifications
You must be signed in to change notification settings - Fork 10
Using SBT
- Make sure you have a sun jvm 1.6+ installed
- Create a shell script called "sbt" (somewhere in your path) with the following in it (note, some settings like the Mesos path and the heap size (-Xmx) should be customized for your setup):
#!/bin/bash
java -noverify -Djava.library.path=/usr/local/mesos/lib/java -Xmx7G -XX:MaxPermSize=3G \
-XX:+UseParNewGC -XX:+UseConcMarkSweepGC -jar `dirname $0`/sbt-launch.jar "$@"
Make sure the permissions for the script are 755.
- Download
sbt-launch
from http://cs.berkeley.edu/~marmbrus/tmp/sbt-launch.jar and put it into the same directory as the above sbt script - Try it out by running sbt while in the top level directory of SCADS (assuming you have already set up your SCADS git repository:
git clone [email protected]:radlab/SCADS.git
) - Run
update
to download all of the managed dependencies - If you want to be able to push your jars to the shared nexus repository, you will need to create a file called ~/.ivy2/.credentials which you have to get from Michael (marmbrus) or Andy (andyk) or anybody else who already has this file.
If you get an error that looks anything like the following, you should delete ~/.m2/repository and ~/.ivy2/cache, and try again.
:: problems summary ::
:::: WARNINGS
[NOT FOUND ] org.scala-lang#scala-compiler;2.8.0!scala-compiler.jar (76ms)
If you get the error java.lang.NoClassDefFoundError: org/apache/avro/Schema
try running update
and then restarting sbt.
SBT is configured by the scala program in project/built/ScadsProject.scala
. Subprojects are specified as lazy vals in the following form:
lazy val subProjectName = project("path to subproject", "subproject name", new ScadsSubProject(_) {
val bdb = "com.sleepycat" % "je" % "4.0.71" //Dependencies are specified using maven style: groupId % artifactId % version
}, config, avro, comm) //any dependencies on other scads components are listed last.
Directory layout for the subproject is the same as with maven (I.e source files go in <subproject dir>/src/main/scala
. If you are creating a subproject in a nested directory each directory should be its own string and the / operator should be used for concatenation (Ex: "piql" / "scadr"
).
SBT commands can either be run one at a time by running sbt <command>
or from the an sbt shell which can be invoked by running sbt
by itself. The shell supports tab completion and successive commands will take advantage of JIT and thus run faster. Unlike with maven all sbt commands should be run from the root of the SCADS checkout, regardless of which subproject you are working on. More commands can be found on the SBT wiki
-
clean
- delete class files for the current subproject and all dependent sub-projects -
compile
- build the current project and all its dependencies -
doc
- compile javadoc -
package
- create the jar or war file for the current project -
project <subproject name>
- switch to the specified subproject, subsequent commands will be run only on this project and its dependencies -
projects
- list all of the available subprojects -
publish
- publish jars to the radlab nexus repository -
publish-local
- publish jars to your local ivy cache. -
reload
- recompiles the project definition and restarts sbt -
run
- run the mainclass for the current subproject, if there are multiple choices you will be prompted for which one you want to run -
test
- run the testcases for the current subproject and all its dependencies -
test-only
- run only the testcases for source that has changed since tests were last run -
update
- download all managed dependencies jars, note in contrast to maven this must be run explicitly. This only needs to be run once unless dependencies have been added to the project. -
write-packaged-classpath
- build jars for the current subproject and all of its dependencies, then output two files: classpath and allJars. These contain the absolute path to the current subproject's jars and all of its dependencies. These files are used by the shell scripts described in the next section.
Note: Any of the above commands can be prefixed with a tilde (ex: ~compile
). SBT will then rerun the command anytime any sourcefile is changed.
Note the following scripts rely on the presence of the classpath and alljars files which are produced by running write-packaged-classpath
-
bin/mvnconsole
- starts up a scala console. unfortunately some log4j configuration is in the classpath, so you'll have to turn off zookeeper logging if you don't want the logs to keep printing. the easiest way to do this is to putorg.apache.log4j.Logger.getLogger("org.apache.zookeeper").setLevel(org.apache.log4j.Level.OFF)
at the top of yoursetup.scala
bootstrap script -
bin/assemble
- builds an uberjar of the current subproject and all its dependencies. the output file will be names scads.jar