mirror of https://github.com/sbt/sbt.git
Added sbt-setup script. Now generates specs test template too.
This commit is contained in:
parent
863073d57a
commit
479f9e5141
|
|
@ -0,0 +1,100 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
|
||||
PROJECT="$1"
|
||||
|
||||
ORGANIZATION="improving"
|
||||
SCALA_VERSION="2.8.1"
|
||||
SCALACHECK_VERSION="1.8"
|
||||
SPECS_VERSION="1.6.7"
|
||||
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_CLASS=$(echo $PROJECT | sed -e 's/[^a-zA-Z_]//g;')Project
|
||||
|
||||
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("2.9.0-local", new java.io.File(path)))
|
||||
}
|
||||
|
||||
val scalacheck = "org.scala-tools.testing" %% "scalacheck" % "$SCALACHECK_VERSION" % "test" withSources()
|
||||
val specs = "org.scala-tools.testing" %% "specs" % "$SPECS_VERSION" % "test" withSources()
|
||||
}
|
||||
EOF
|
||||
|
||||
cat > project/build.properties <<EOF
|
||||
#Project properties
|
||||
#Generated by sbt-setup
|
||||
project.organization=$ORGANIZATION
|
||||
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 $ORGANIZATION
|
||||
|
||||
object Main {
|
||||
def main(args: Array[String]): Unit = {
|
||||
// Your code here
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
mkdir -p src/test/scala
|
||||
|
||||
cat > src/test/scala/TemplateSpec.scala <<EOF
|
||||
package $ORGANIZATION
|
||||
|
||||
import org.specs._
|
||||
|
||||
class TemplateSpec extends Specification {
|
||||
"A template project" should {
|
||||
"not violate universal realities" >> {
|
||||
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"
|
||||
Loading…
Reference in New Issue