Skip to content

Instantly share code, notes, and snippets.

@casualjim
Created June 12, 2011 08:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save casualjim/1021348 to your computer and use it in GitHub Desktop.
Save casualjim/1021348 to your computer and use it in GitHub Desktop.
import sbt._
import Keys._
import org.sbtidea._
import SbtIdeaPlugin._
import Scope.{GlobalScope, ThisScope}
object BuildSettings {
val buildOrganization = "com.mojolly.backchat"
val buildScalaVersion = "2.9.0-1"
val buildVersion = "0.8.1-SNAPSHOT"
val buildSettings = Defaults.defaultSettings ++
seq(ProguardPlugin.proguardSettings:_*) ++
Seq (
organization := buildOrganization,
scalaVersion := buildScalaVersion,
version := buildVersion,
parallelExecution := false,
retrieveManaged := true,
externalResolvers <<= resolvers map { rs =>
Resolver.withDefaultResolvers(rs, mavenCentral = false, scalaTools = false)
},
resolvers ++= Seq(Resolvers.MavenCentral),
moduleConfigurations ++= Resolvers.moduleConfigurations,
javacOptions ++= Seq("-Xlint:unchecked"),
publishTo := Some(Resolvers.MojollyReleases),
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials"),
scalacOptions ++= Seq("-deprecation", "-unchecked", "-Xcheckinit", "-encoding", "utf8"),
shellPrompt := ShellPrompt.buildShellPrompt)
}
// Shell prompt which show the current project, git branch and build version
// git magic from Daniel Sobral, adapted by Ivan Porto Carrero
object ShellPrompt {
object devnull extends ProcessLogger {
def info (s: => String) {}
def error (s: => String) { }
def buffer[T] (f: => T): T = f
}
val current = """\*\s+([^\s]+)""".r
def gitBranches = ("git branch --no-color" lines_! devnull mkString)
val buildShellPrompt = {
(state: State) => {
val currBranch = current findFirstMatchIn gitBranches map (_ group(1)) getOrElse "-"
val currProject = Project.extract (state).currentProject.id
"%s:%s:%s> ".format (currBranch, currProject, BuildSettings.buildVersion)
}
}
}
object Resolvers {
val sonatypeSnapsots = "Sonatype Nexus Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"
val MavenCentral = "Mojolly Nexus" at "http://maven.mojolly.com/content/repositories/central/"
val AkkaRepo = "Akka Repository" at "http://maven.mojolly.com/content/repositories/akka-repo/"
val JavaNetRepo = "Java.Net Repository" at "http://maven.mojolly.com/content/repositories/java.net-m2/"
val CodehausRepo = "Codehaus Repo" at "http://maven.mojolly.com/content/repositories/codehaus/"
val GuiceyFruitRepo = "Guicey fruit repo" at "http://maven.mojolly.com/content/repositories/guicey-fruit/"
val JBossRepo = "JBoss Netty Repo" at "http://maven.mojolly.com/content/repositories/jboss/"
val ThirdPartySnapshot = "Mojolly 3rd party snapshot" at "http://maven.mojolly.com/content/repositories/thirdparty-snapshots"
val ThirdParty = "Mojolly 3rd party" at "http://maven.mojolly.com/content/repositories/thirdparty"
val BumReleasesRepo = "Bum networks Release Repo" at "http://maven.mojolly.com/content/repositories/bumnetworks-releases/"
val BumSnapshotRepo = "Bum networks snapshot Repo" at "http://maven.mojolly.com/content/repositories/bumnetworks-snapshots/"
val GlassfishRepo = "Glassfish Repo" at "http://maven.mojolly.com/content/repositories/glassfish-repo/"
val SonatypeReleaseRepo = "Sonatype OSS Releases" at "http://maven.mojolly.com/content/repositories/sonatype-oss-releases/"
val CodaHaleRepo = "Coda Hale's Repository" at "http://maven.mojolly.com/content/repositories/codahale/"
val MojollyReleases = "Mojolly Releases" at "http://maven.mojolly.com/content/repositories/releases"
val MojollySnapshots = "Mojolly Snapshots" at "http://maven.mojolly.com/content/repositories/snapshots"
val ScalaToolsReleasesRepo = "ScalaTools Releases" at "http://maven.mojolly.com/content/repositories/scala-tools-releases"
val ScalaToolsSnapshotsRepo = "ScalaTools Snapshots" at "http://maven.mojolly.com/content/repositories/scala-tools-snapshots"
val FuseSourceSnapshots = "FuseSource Snapshot Repository" at "http://repo.fusesource.com/nexus/content/repositories/snapshots"
val FuseSourceReleases = "FuseSource Snapshot Repository" at "http://repo.fusesource.com/nexus/content/groups/public"
val SonatypeSnapshotRepo = MavenRepository("Sonatype Nexus Snapshots", "https://oss.sonatype.org/content/repositories/snapshots")
val moduleConfigurations = Seq(
ModuleConfiguration("superfeedr", ThirdParty),
ModuleConfiguration("com.google.libphonenumber", ThirdParty),
ModuleConfiguration("org.clapper", ScalaToolsReleases),
ModuleConfiguration("org.codeahus.groovy", CodehausRepo),
ModuleConfiguration("com.weiglewilczek.slf4s", ScalaToolsReleases),
ModuleConfiguration("org.glassfish.grizzly", "Glassfish" at "http://maven.mojolly.com/content/repositories/glassfish-repo/"),
ModuleConfiguration("com.mojolly", if (Dependencies.isBackchatSnapshot) MojollySnapshots else MojollyReleases),
ModuleConfiguration("com.mojolly.logback", MojollySnapshots),
ModuleConfiguration("org.guiceyfruit", GuiceyFruitRepo),
ModuleConfiguration("org.glassfish", GlassfishRepo),
ModuleConfiguration("org.glassfish.extras", GlassfishRepo),
ModuleConfiguration("org.glassfish.gmbal", JavaNetRepo),
ModuleConfiguration("org.glassfish.external", JavaNetRepo),
ModuleConfiguration("org.glassfish.grizzly", ThirdParty),
ModuleConfiguration("org.jboss", JBossRepo),
ModuleConfiguration("com.sun.jersey.contribs", JavaNetRepo),
ModuleConfiguration("com.sun.jersey", JavaNetRepo),
ModuleConfiguration("org.multiverse", CodehausRepo),
ModuleConfiguration("org.jboss.netty", JBossRepo),
ModuleConfiguration("voldemort.store.compress", AkkaRepo),
ModuleConfiguration("com.eaio", ThirdParty),
ModuleConfiguration("com.fotolog", ThirdParty),
ModuleConfiguration("sbinary", AkkaRepo),
ModuleConfiguration("sjson.json", ThirdParty),
ModuleConfiguration("net.debasishg", ScalaToolsReleases),
ModuleConfiguration("net.lag", "configgy", AkkaRepo),
ModuleConfiguration("org.codehaus.aspectwerkz", AkkaRepo),
ModuleConfiguration("jsr166x", AkkaRepo),
ModuleConfiguration("org.scala-tools", "vscaladoc", AkkaRepo),
ModuleConfiguration("se.scalablesolutions.akka", AkkaRepo),
ModuleConfiguration("org.scalatra", ThirdPartySnapshot)
)
}
object Dependencies {
val backchatLibraryVersion = "0.3.3-SNAPSHOT"
val akkaVersion = "1.1.2"
val liftVersion = "2.4-M1"
val scalaTestVersion = "1.4.1"
val casbahVersion = "2.1.5-1"
val slf4jVersion = "1.6.1"
val specsVersion = "1.6.8"
val specs2Version = "1.4"
val luceneVersion = "3.0.3"
val elasticSearchVersion = "0.16.1"
val jettyVersion = "8.0.0.M3"
val jettyServletApi = "3.0.20100224"
val gfServletApi = "3.1"
val parboiledVersion = "1.0.0"
val jedisVersion = "1.5.2"
val asyncHttpClientVersion = "1.6.3"
val dispatchVersion = "0.7.8"
val tikaVersion = "0.8"
val scalatraVersion = "2.0.0-SNAPSHOT"
val grizzlyVersion = "2.1.1"
def isBackchatSnapshot = backchatLibraryVersion.endsWith("-SNAPSHOT")
def backchat(name: String) = "com.mojolly" %% "backchat-%s".format(name) % backchatLibraryVersion
def dispatch(name: String) = "net.databinder" %% "dispatch-%s".format(name) % dispatchVersion
def akka(name: String) = "se.scalablesolutions.akka" % "akka-%s".format(name) % akkaVersion
def scalatra(name: String) = "org.scalatra" %% "scalatra-%s".format(name) % scalatraVersion
def grizzly(name: String) = "org.glassfish.grizzly" % "grizzly-%s".format(name) % grizzlyVersion
val backchatEmail = backchat("email")
val backchatBql = backchat("bql")
val backchatTwitter = backchat("twitter")
val backchatAuditing = backchat("auditing")
val backchatMongoDB = backchat("mongodb")
val backchatRedis = backchat("redis")
val dispatchHttpJson = dispatch("http-json")
val dispatchOAuth = dispatch("oauth")
val objenesis = "org.objenesis" % "objenesis" % "1.2"
val akkaHttp = akka("http")
val libPhoneNumber = "com.google.libphonenumber" % "libphonenumber" % "2.4"
val scalaTest = "org.scalatest" % "scalatest_2.9.0" % scalaTestVersion % "test->compile"
val scalaCheck = "org.scala-tools.testing" %% "scalacheck" % "1.9" % "test->compile"
val specs = "org.scala-tools.testing" %% "specs" % specsVersion % "test->compile"
val specs2 = "org.specs2" %% "specs2" % specs2Version % "test->compile"
val mockito = "org.mockito" % "mockito-all" % "1.8.5" % "test->compile"
val subethaSmtp = "org.subethamail" % "subethasmtp" % "3.1.4.1"
val smackx = "jivesoftware" % "smackx" % "3.1.0"
val superfeedr = "superfeedr" % "superfeedr" % "1.1"
val backchatScalatra = backchat("scalatra")
val scalatraAuth = scalatra("auth")
val scalatraFileUpload = scalatra("fileupload")
val scalatraSpecs = scalatra("specs") % "test->compile"
val servletApi = "org.glassfish" % "javax.servlet" % gfServletApi
val grizzlyWebsockets = grizzly("websockets")
val grizzlyFramework = grizzly("framework")
val grizzlyComet = grizzly("comet")
val grizzlyServlet = grizzly("http-servlet")
val memoryIndexer = "org.apache.lucene" % "lucene-memory" % luceneVersion
val slf4j = "org.slf4j" % "slf4j-api" % slf4jVersion
}
object BackendBuild extends Build {
val buildShellPrompt = ShellPrompt.buildShellPrompt
import Resolvers._
import Dependencies._
import BuildSettings._
val printClasspath = TaskKey[File]("print-class-path")
def printCp = (target, fullClasspath in Compile, compile in Compile) map { (out, cp, analysis) =>
println(cp.files.map(_.getName).mkString("\n"))
println("----")
println(analysis.relations.allBinaryDeps.toSeq.mkString("\n"))
println("----")
println(out)
out
}
val testDeps = Seq (scalaTest, specs, scalaCheck, mockito)
val grizzlyServer = Seq(grizzlyWebsockets, grizzlyFramework, grizzlyComet, grizzlyServlet)
val webDeps = Seq(backchatScalatra, scalatraAuth, scalatraFileUpload, scalatraSpecs) ++ grizzlyServer ++ testDeps
lazy val root = Project ("backend", file("."), settings = buildSettings)) aggregate(web, streamer, tracker)
lazy val models = Project ("backend-models", file("mongo"),
settings = buildSettings :+ (libraryDependencies := testDeps) ) dependsOn(core) aggregate(core)
lazy val web = Project ("backend-web", file("web"), settings = (buildSettings ++ Seq (
libraryDependencies := webDeps,
mainClass := Some("com.mojolly.backchat.web.BackchatWebServer"),
printClasspath <<= printCp))) dependsOn(core, models % "compile;test->test")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment