sbt/bin/sbt-setup

103 lines
2.3 KiB
Plaintext
Raw Normal View History

#!/bin/bash
#
PROJECT="$1"
DEFAULT_PACKAGE="template"
PACKAGE=${ORGANIZATION:-$DEFAULT_PACKAGE}
SCALA_VERSION="2.8.1"
SCALA_LOCAL_VERSION="2.9.0-local"
SBT_VERSION="0.7.5.RC0"
if [ -z "$PROJECT" ]; then
echo "Usage: $0 <project name>"
exit 1
fi
DIR=$(echo ${PROJECT} | tr '[A-Z]' '[a-z]')
PROJECT_UC=$(echo ${PROJECT:0:1} | tr '[a-z]' '[A-Z]')$(echo ${PROJECT:1} | sed -e 's/[^a-zA-Z_]//g;')
PROJECT_CLASS=${PROJECT_UC}Project
SPEC_CLASS=${PROJECT_UC}Spec
mkdir $DIR
cd $DIR
echo "Creating sbt project ${PROJECT} in ${PWD}"
echo ""
cat > .gitignore <<EOF
target
/project/boot
lib_managed
src_managed
/ext
EOF
mkdir -p project/build
cat > project/build/${PROJECT_CLASS}.scala <<EOF
import sbt._
class ${PROJECT_CLASS}(info: ProjectInfo) extends DefaultProject(info) {
val localMaven = "Local Maven" at "file://"+Path.userHome+"/.m2/repository"
val localIvy = "Local Ivy" at "file://"+Path.userHome+"/.ivy2/local"
val sonatype = "Sonatype" at "https://oss.sonatype.org/content/groups/public"
// local use
override def localScala = System.getenv("scala.local") match {
case null => super.localScala
case path =>
log.info("Found scala.local: " + path)
List(defineScala("$SCALA_LOCAL_VERSION", new java.io.File(path)))
}
val scalacheck = "org.scala-tools.testing" %% "scalacheck" % "latest.integration" % "test" withSources()
val specs = "org.scala-tools.testing" %% "specs" % "latest.integration" % "test" withSources()
}
EOF
cat > project/build.properties <<EOF
#Project properties
#Generated by sbt-setup
project.organization=$PACKAGE
project.name=$PROJECT
sbt.version=$SBT_VERSION
project.version=0.1
build.scala.versions=$SCALA_VERSION
project.initialize=false
EOF
mkdir -p src/main/scala
cat > src/main/scala/Main.scala <<EOF
package $PACKAGE
object Main {
def main(args: Array[String]): Unit = {
// Your code here
}
}
EOF
mkdir -p src/test/scala
cat > src/test/scala/${SPEC_CLASS}.scala <<EOF
package $PACKAGE
import org.specs._
class ${SPEC_CLASS} extends Specification {
"A skeletal specification" should {
"do little beyond creating a skeleton" >> {
1 mustEqual 1
}
}
}
EOF
git init
git add .
git commit -m "Initial Import for ${PROJECT} (autogenerated by sbt-setup)."
sbt update
echo ""
echo "Ready to roll in $PWD"