2011-02-14 19:57:45 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
PROJECT="$1"
|
|
|
|
|
|
2011-02-14 20:32:38 +01:00
|
|
|
DEFAULT_PACKAGE="template"
|
|
|
|
|
PACKAGE=${ORGANIZATION:-$DEFAULT_PACKAGE}
|
2011-02-14 19:57:45 +01:00
|
|
|
SCALA_VERSION="2.8.1"
|
2011-02-15 05:24:03 +01:00
|
|
|
SCALA_LOCAL_VERSION="2.9.0-local"
|
2011-02-14 19:57:45 +01:00
|
|
|
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]')
|
2011-02-15 05:24:03 +01:00
|
|
|
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
|
2011-02-14 19:57:45 +01:00
|
|
|
|
|
|
|
|
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) {
|
2011-02-15 05:24:03 +01:00
|
|
|
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"
|
2011-02-14 19:57:45 +01:00
|
|
|
|
|
|
|
|
// local use
|
|
|
|
|
override def localScala = System.getenv("scala.local") match {
|
|
|
|
|
case null => super.localScala
|
|
|
|
|
case path =>
|
|
|
|
|
log.info("Found scala.local: " + path)
|
2011-02-15 05:24:03 +01:00
|
|
|
List(defineScala("$SCALA_LOCAL_VERSION", new java.io.File(path)))
|
2011-02-14 19:57:45 +01:00
|
|
|
}
|
|
|
|
|
|
2011-02-15 05:24:03 +01:00
|
|
|
val scalacheck = "org.scala-tools.testing" %% "scalacheck" % "latest.integration" % "test" withSources()
|
|
|
|
|
val specs = "org.scala-tools.testing" %% "specs" % "latest.integration" % "test" withSources()
|
2011-02-14 19:57:45 +01:00
|
|
|
}
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
cat > project/build.properties <<EOF
|
|
|
|
|
#Project properties
|
|
|
|
|
#Generated by sbt-setup
|
2011-02-14 20:32:38 +01:00
|
|
|
project.organization=$PACKAGE
|
2011-02-14 19:57:45 +01:00
|
|
|
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
|
2011-02-14 20:32:38 +01:00
|
|
|
package $PACKAGE
|
2011-02-14 19:57:45 +01:00
|
|
|
|
|
|
|
|
object Main {
|
|
|
|
|
def main(args: Array[String]): Unit = {
|
|
|
|
|
// Your code here
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
mkdir -p src/test/scala
|
|
|
|
|
|
2011-02-15 05:24:03 +01:00
|
|
|
cat > src/test/scala/${SPEC_CLASS}.scala <<EOF
|
2011-02-14 20:32:38 +01:00
|
|
|
package $PACKAGE
|
2011-02-14 19:57:45 +01:00
|
|
|
|
|
|
|
|
import org.specs._
|
|
|
|
|
|
2011-02-15 05:24:03 +01:00
|
|
|
class ${SPEC_CLASS} extends Specification {
|
|
|
|
|
"A skeletal specification" should {
|
|
|
|
|
"do little beyond creating a skeleton" >> {
|
2011-02-14 19:57:45 +01:00
|
|
|
1 mustEqual 1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
git init
|
|
|
|
|
git add .
|
|
|
|
|
git commit -m "Initial Import for ${PROJECT} (autogenerated by sbt-setup)."
|
|
|
|
|
sbt update
|
|
|
|
|
|
|
|
|
|
echo ""
|
2011-02-15 05:24:03 +01:00
|
|
|
echo "Ready to roll in $PWD"
|