Skip to content

Instantly share code, notes, and snippets.

@epost
Last active August 29, 2015 14:02
Show Gist options
  • Save epost/486af196de8f4d324a7e to your computer and use it in GitHub Desktop.
Save epost/486af196de8f4d324a7e to your computer and use it in GitHub Desktop.
Example SBT web project for Vlad

SBT web project template

  • I always use paulp’s startup script which automatically fetches the right SBT dependencies. It’s great!
  • I’m currently running SBT 13.5 which seems to be working out ok. Before that, 13.2.
  • Make sure you put these files into the project/ subdir
  • create a WAR using sbt packageWar
sbt.version=0.13.5
import sbt._
import sbt.Keys._
import com.earldouglas.xsbtwebplugin.WebPlugin
import com.earldouglas.xsbtwebplugin.PluginKeys._
import Tests._
/*
// don't monitor dirs when using JRebel
scanDirectories := Nil
Note: putting any any JDBC driver into the container's classpath (i.e., Jetty) is the better way. Otherwise, if you put the driver into the .war, you'll most likely end up with class / permgen leakage if you redeploy your webapp. (Because java.sql.Driver holds a reference to all loaded drivers)
... dependsOn(RootProject(uri("git://github.com/epost/liftmodules-widgets.git#lift-2.6-M1")))
*/
object FooBarBazBuild extends Build {
val repoKind = SettingKey[String]("repo-kind", """Maven repository kind ("snapshots" or "releases")""")
val liftVersion = "2.6-M4"
lazy val foobarbazLiftwebProject = Project(
id = "foobarbaz-liftweb",
base = file("."),
settings =
Project.defaultSettings ++
Seq(
name := "foobarbaz-liftweb",
description := "Foobarbaz Lift app",
libraryDependencies <++= scalaVersion(sv => Seq(
"org.eclipse.jetty" % "jetty-webapp" % "7.3.0.v20110203" % "test,container"
)),
parallelExecution in Test := false,
initialCommands := "import scalaz._, Scalaz._"
//jarName <<= (name, version) { (name: String, version: String) => name + "-" + version + ".jar" }
) ++
sharedSettings ++
WebPlugin.webSettings ++
inConfig(WebPlugin.container.Configuration) (Seq(
port := 8080)
) ++
Seq(dumpTempDirTask)
)
lazy val sharedSettings = /* super.settings ++ */ Seq(
organization := "nl.shinsetsu",
organizationName := "Shinsetsu",
scalaVersion := "2.10.4",
scalacOptions ++= List("-deprecation", "-unchecked"), // "-Xlint"
libraryDependencies ++= Seq(
"org.scalaz" %% "scalaz-core" % "7.1.0-M7" withSources,
"org.scalaz" %% "scalaz-effect" % "7.1.0-M7" withSources,
"org.typelevel" %% "shapeless-scalaz" % "0.1.2",
"net.liftweb" %% "lift-webkit" % liftVersion % "compile->default" withSources,
"net.liftmodules" %% "imaging_2.6" % "1.2" withSources,
"org.slf4j" % "slf4j-log4j12" % "1.6.1",
"org.bouncycastle" % "bcprov-jdk16" % "1.46",
"junit" % "junit" % "4.5" % "test->default",
"org.scala-tools.testing" %% "specs" % "1.6.9" % "test->default", // TODO eliminate
"org.specs2" %% "specs2" % "1.13" % "test",
"net.liftweb" %% "lift-testkit" % liftVersion % "test->default" withSources,
"com.typesafe.slick" %% "slick" % "2.0.2",
"org.postgresql" % "postgresql" % "9.3-1100-jdbc4" % "compile->default",
"com.zaxxer" % "HikariCP" % "1.3.5" withSources
, "org.scalikejdbc" %% "scalikejdbc" % "2.0.0" % "test->default"
, "ch.qos.logback" % "logback-classic" % "1.1.0"
),
logBuffered := false,
resolvers += Resolver.sonatypeRepo("snapshots"),
repoKind <<= (version)(v => if(v.trim.endsWith("SNAPSHOT")) "snapshots" else "releases"),
//publishTo <<= (repoKind)(r => Some(Resolver.file("test", file("c:/temp/repo/"+r)))),
//publishTo <<= (repoKind) {
// case "snapshots" => Some("snapshots" at "https://oss.sonatype.org/content/repositories/snapshots")
// case "releases" => Some("releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2")
//},
publishMavenStyle := true,
publishArtifact in Test := false,
pomIncludeRepository := { _ => false },
makePomConfiguration ~= { _.copy(configurations = Some(Seq(Compile, Runtime, Optional))) },
homepage := Some(url("http://www.foobarbaz.nl")),
startYear := Some(2013),
licenses += ("Proprietary", url("http://www.foobarbaz.nl/LICENSE.txt")),
pomExtra :=
<scm>
<url>https://bitbucket.org/yourname/foobarbaz-scala/</url>
<connection>scm:git:git@bitbucket.org:yourname/foobarbaz-scala.git</connection>
</scm>
)
// example task
val dumpTempDir = TaskKey[Unit]("dumpTempDir", "Dumps the temp directory to the console.")
val dumpTempDirTask = dumpTempDir := {
println(sys.props("java.io.tmpdir"))
}
}
addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "0.4.2")
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment