#!/usr/bin/env bash # BINDIR=$(abspath $(dirname "$0")) . $BINDIR/util.sh BASE=$(abspath $BINDIR/..) declare -a args TEMPLATE="simple" SCALA_VERSION="2.8.1" PROJECT_VERSION="0.0.1" DO_GITHUB= while [ $# -gt 0 ]; do case "$1" in --simple) TEMPLATE="simple" shift ;; --fancy) TEMPLATE="fancy" shift ;; --version) shift PROJECT_VERSION="$1" shift ;; --github) shift DO_GITHUB="true" ;; --28) SCALA_VERSION="2.8.1" shift ;; --29) SCALA_VERSION="2.9.0.RC1" shift ;; *) args=("${args[@]}" "$1") shift ;; esac done # reset "$@" to the remaining args set -- "${args[@]}" if [[ $# -ne 1 ]]; then cat < [dependencies] --hub create github project (requires hub and more) --simple use simple project template --fancy use multi-file project template --28 latest release of scala 2.8.x --29 latest release of scala 2.9.x --version project initial version EOM exit 1 fi if [ -z "$1" ]; then echo "Usage: $0 " exit 1 fi PROJECT="$1" PACKAGE=${ORGANIZATION:-template} SBT_VERSION="0.7.6.RC0" DIR=$(echo ${PROJECT} | tr '[A-Z]' '[a-z]') PROJECT_CC=`camelCase ${PROJECT}` PROJECT_CLASS=${PROJECT_CC}Project SPEC_CLASS=${PROJECT_CC}Spec [[ -e $DIR ]] && { echo "$DIR exists, please remove it first." ; exit 1; } mkdir -p $DIR cd $DIR echo "Creating \"${PACKAGE} % ${PROJECT} % ${PROJECT_VERSION}\" from template \"$TEMPLATE\"." echo "Building against scala $SCALA_VERSION with sbt $SBT_VERSION." echo "Repository in ${PWD} ." echo for dir in project/build project/plugins src/main/scala src/main/java src/test/scala src/test/java do mkdir -p $dir done cat > project/build.properties < src/main/scala/Main.scala < src/test/scala/${SPEC_CLASS}.scala <> { 1 mustEqual 1 } } } EOF FILE=project/build/${PROJECT_CLASS}.scala if [[ $TEMPLATE == "fancy" ]]; then cp $BASE/src/template/Libraries.scala project/build cp $BASE/src/template/Repositories.scala project/build cp $BASE/src/template/Plugins.scala project/plugins cat > $FILE < $FILE <> $FILE cp $BASE/src/template/Plugins.scala project/plugins fi ln -s $FILE cat > .gitignore <