Skip to content

Instantly share code, notes, and snippets.

@fmpwizard
Forked from eltimn/Build.scala
Created September 7, 2013 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmpwizard/6475604 to your computer and use it in GitHub Desktop.
Save fmpwizard/6475604 to your computer and use it in GitHub Desktop.
import sbt._
import sbt.Keys._
object MyBuild extends Build {
import Dependencies._
import BuildSettings._
lazy val main = Project("root", file("."))
.settings(mainWebSettings: _*)
.settings(
warName := "myweb.war",
serverName := "mysrvr"
)
.settings(libraryDependencies ++=
compile(
liftWebkit,
logback
) ++
container(jettyWebapp) ++
test(scalatest)
)
}
import sbt._
import Keys._
import com.github.siasia.WebPlugin._
import com.github.siasia.PluginKeys._
object BuildSettings {
// Deployment
val serverName = SettingKey[String]("server-name")
val warName = SettingKey[String]("war-name")
val deployWar = TaskKey[Unit]("deploy-war", "Deploy WAR")
def deployWarTask = ((packageWar in Compile), warName, serverName, streams) map {
(war, name, srvr, s) =>
if (war.exists) {
s.log.info("Deploying war "+name)
deployWar(war.getAbsolutePath, name, srvr)
}
else
sys.error("There was a problem locating the WAR file for this project")
}
private def deployWar(src: String, dest: String, srvr: String): Unit = {
"scp %s %s:/opt/jetty/webapps/%s".format(src, srvr, dest) !
}
lazy val basicSettings = seq(
version := "1.0.0",
organization := "myorg",
scalaVersion := "2.10.1",
scalacOptions := Seq("-deprecation", "-unchecked", "-encoding", "utf8"),
resolvers ++= Dependencies.resolutionRepos
)
lazy val noPublishing = seq(
publish := (),
publishLocal := ()
)
lazy val mainWebSettings =
basicSettings ++
webSettings ++
seq(
// deployment
deployWar <<= deployWarTask
)
}
import sbt._
object Dependencies {
val resolutionRepos = Seq(
"Sonatype Snapshot" at "http://oss.sonatype.org/content/repositories/snapshots"
)
def compile(deps: ModuleID*): Seq[ModuleID] = deps map (_ % "compile")
def provided(deps: ModuleID*): Seq[ModuleID] = deps map (_ % "provided")
def test(deps: ModuleID*): Seq[ModuleID] = deps map (_ % "test")
def runtime(deps: ModuleID*): Seq[ModuleID] = deps map (_ % "runtime")
def container(deps: ModuleID*): Seq[ModuleID] = deps map (_ % "container")
object Ver {
val lift = "2.5"
val lift_edition = "2.5"
val jetty = "8.1.8.v20121106"
}
// Lift
val liftWebkit = "net.liftweb" %% "lift-webkit" % Ver.lift
// Jetty
val jettyWebapp = "org.eclipse.jetty" % "jetty-webapp" % Ver.jetty
// Misc
val logback = "ch.qos.logback" % "logback-classic" % "1.0.3"
val scalatest = "org.scalatest" %% "scalatest" % "1.9.1"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment