#!/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 " 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 < project/build/Libraries.scala < ModuleID) object ArtifactConfig { implicit def defaultArtifactConfig: ArtifactConfig = new ArtifactConfig("", identity[ModuleID]) implicit def testArtifactConfig: ArtifactConfig = new ArtifactConfig("test", identity[ModuleID]) } trait LowPriorityLibraries { self: DefaultProject => // "latest.integration", "latest.milestone", "latest.release" def defaultRevision = "latest.integration" protected implicit def defaultArtifactRevision = new ArtifactRevision(defaultRevision) // protected implicit def defaultArtifactConfig = new ArtifactConfig("", identity[ModuleID]) protected implicit def autoConfig (artifact: GroupArtifactID) (implicit rev: ArtifactRevision, config: ArtifactConfig): ModuleID = { val ArtifactConfig(confs, fn) = config fn( if (confs == "") artifact % rev.revision else artifact % rev.revision % config.confs ) } } trait TestLibraries extends LowPriorityLibraries { self: DefaultProject => private implicit val testDepConfig = ArtifactConfig("test", _.withSources) val specs: ModuleID = "org.scala-tools.testing" %% "specs" val scalacheck: ModuleID = "org.scala-tools.testing" %% "scalacheck" } trait Libraries extends Repositories with TestLibraries { self: DefaultProject => import ArtifactConfig.defaultArtifactConfig // val ant: ModuleID = "org.apache.ant" % "ant" // val asmAll: ModuleID = "asm" % "asm-all" withSources() // val easymock: ModuleID = "org.easymock" % "easymock" // val guava: ModuleID = "com.google.guava" % "guava" // val ivy: ModuleID = "org.apache.ivy" % "ivy" // val jdt: ModuleID = "org.eclipse.jdt" % "core" notTransitive() // val jetty: ModuleID = "org.mortbay.jetty" % "jetty" // val jmock: ModuleID = "org.jmock" % "jmock" // val jodaTime: ModuleID = "joda-time" % "joda-time" // val liftJson: ModuleID = "net.liftweb" %% "lift-json" // val maven: ModuleID = "org.apache.maven" % "maven-ant-tasks" // val scalaARM: ModuleID = "com.github.jsuereth.scala-arm" %% "scala-arm" withSources() val scalaImproving: ModuleID = "org.improving" %% "scala-improving" // val scalaSTM: ModuleID = "org.scala-tools" %% "scala-stm" // val scalariform: ModuleID = "org.scalariform" %% "scalariform" // val scalazCore: ModuleID = "org.scalaz" %% "scalaz-core" withSources() // val scalazHttp: ModuleID = "org.scalaz" %% "scalaz-http" withSources() // val slf4s: ModuleID = "com.weiglewilczek.slf4s" %% "slf4s" withSources() } EOF cat > project/build/Repositories.scala < 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" val scalaToolsSnapshots = "Scala Tools Snapshots" at "http://scala-tools.org/repo-snapshots/" val jboss = "JBoss Repo" at "http://repository.jboss.org/maven2" } EOF cat > project/build/${PROJECT_CLASS}.scala < super.localScala case path => log.info("Found scala.local: " + path) List(defineScala("$SCALA_LOCAL_VERSION", new java.io.File(path))) } } EOF mkdir -p project/plugins cat > project/plugins/Plugins.scala < project/build.properties < src/main/scala/Main.scala < src/test/scala/${SPEC_CLASS}.scala <> { 1 mustEqual 1 } } } EOF git init git add . git commit -m "Initial Import for ${PROJECT} (autogenerated by sbt-setup)." sbt update sbt update echo "" echo "Ready to roll in $PWD"