sbt tutorial
sbt (Scala Build Tool) とは、ビルドツール
https://github.com/harrah/xsbt
ビルドツールとは、
- コンパイルツール
コンパイル以外にも、以下を行う
- 依存ライブラリのダウンロード(ivyの機能)
- ユニットテスト実行
- jarファイル生成
Scala版Ant
play2 コマンドはsbt-launch.jarの呼び出し
emole:diva-alpha magnet$ which play2 /usr/local/bin/play2 emole:diva-alpha magnet$ cat /usr/local/bin/play2 #! /usr/bin/env sh PRG="$0" while [ -h "$PRG" ] ; do PRG=`readlink "$PRG"` done dir=`dirname $PRG` if [ -f conf/application.conf ]; then if test "$1" = "clean-all"; then rm -rf target rm -rf tmp rm -rf logs rm -rf dist rm -rf project/project rm -rf project/target if [ $# -ne 1 ] then shift else echo "[info] Done!" exit 0 fi fi if test "$1" = "stop"; then if [ -f RUNNING_PID ]; then echo "[info] Stopping application (with PID `cat RUNNING_PID`)..." kill `cat RUNNING_PID` RESULT=$? if test "$RESULT" = 0; then echo "[info] Done!" exit 0 else echo "[\033[31merror\033[0m] Failed ($RESULT)" exit $RESULT fi else echo "[\033[31merror\033[0m] No RUNNING_PID file. Is this application running?" exit 1 fi fi if test "$1" = "debug"; then JPDA_PORT="9999" shift fi if [ -n "$1" ]; then JPDA_PORT="${JPDA_PORT}" $dir/framework/build "$@" else JPDA_PORT="${JPDA_PORT}" $dir/framework/build play fi else java -Dsbt.ivy.home=$dir/repository -Dplay.home=$dir/framework -Dsbt.boot.properties=$dir/framework/sbt/play.boot.properties -jar $dir/framework/sbt/sbt-launch.jar "$@" fi emole:diva-alpha magnet$
build.sbt で使用できる記述
libraryDependencies
plugins.sbt: sbt プラグインを使用している
play2 は、Play sbt plugin を使用している
emole:project magnet$ cat project/plugins.sbt // Comment to get more information during initialization logLevel := Level.Warn // The Typesafe repository resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/" // Use the Play sbt plugin for Play projects addSbtPlugin("play" % "sbt-plugin" % "2.0")
scalaでつかえるdatabase framework
http://stackoverflow.com/questions/1362748/wanted-good-examples-of-scala-database-persistence