The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

globulon (18) [Avatar] Offline
#1
Hello,

1. web.xml

Just at the end of 5.4.2 I suggest that the location of the web.xml file may not be src/webapp/WEB-INF but src/main/webapp/WEB-INF

2.Code compile

With Scalaz-http 6.0.1 you have a code compile error if you do not put

HttpServlet.resource(found, NotFound.xhtml)

There is a conflict on the resource name importing Scalaz._ and HttpServlet._

3. sbt I finally succeeded in setting something with sb 0.10.x:

If it can help:

import sbt._
import Keys._
import com.github.siasia.WebPlugin._


object BuildSettings {
val buildSettings = Defaults.defaultSettings ++ Seq (
organization := "com.promindis",
version := "0.1-SNAPSHOT",
scalaVersion := "2.9.0-1",
scalacOptions := Seq("-unchecked", "-deprecation"),
crossScalaVersions := Seq("2.9.0-1", "2.9.1.RC4")
)
}

object Resolvers {
val scalaToolsReleases = "Scala-Tools Maven2 Releases Repository" at "http://scala-tools.org/repo-releases"
val scalaToolsSnapshots = "Scala-Tools Maven2 Snapshots Repository" at "http://scala-tools.org/repo-snapshots"

}

object ScalazDependencies {
lazy val scalazVersion = "6.0.1"
lazy val scalazCore = "org.scalaz" %% "scalaz-core" % scalazVersion
lazy val scalazHttp = "org.scalaz" %% "scalaz-http" % scalazVersion
}

object JettyDependencies {
lazy val jettyVersion = "7.3.0.v20110203"
lazy val jettyServlet = "org.eclipse.jetty" % "jetty-servlet" % jettyVersion
lazy val jetty7 = "org.eclipse.jetty" % "jetty-webapp" % jettyVersion % "test, jetty"
lazy val jettyServer = "org.eclipse.jetty" % "jetty-server" % jettyVersion
}

object Dependencies {
val testDependencies = Seq(libraryDependencies <<= (scalaVersion, libraryDependencies) { (version, dependencies) =>
val specs2Version = version match {
case "2.9.1.RC4" => "1.6-SNAPSHOT"
case _ => "1.5"
}
dependencies :+ ("org.specs2" %% "specs2" % specs2Version % "test")
})
}

object MainBuild extends Build {
import Resolvers._
import Dependencies._
import BuildSettings._
import JettyDependencies._
import ScalazDependencies._

lazy val wekanban = Project(
"wekanban",
file("."),
settings = buildSettings ++ testDependencies ++ webSettings ++ Seq (
libraryDependencies ++= Seq(jettyServlet, jetty7, jettyServer, scalazCore, scalazHttp)
)
)
}

You migh notice the import of siasia web plugin.

So to plug it I used the build.sbt file under the plugins directory:

resolvers ++= Seq(
"Web plugin repo" at "http://siasia.github.com/maven2",
Resolver.url("Typesafe repository", new java.net.URL("http://typesafe.artifactoryonline.com/typesafe/ivy-releases/"))(Resolver.defaultIvyPatterns)
)

//Following means libraryDependencies += "com.github.siasia" %% "xsbt-web-plugin" % "0.1.0-<sbt version>""
libraryDependencies <+= sbtVersion(v => "com.github.siasia" %% "xsbt-web-plugin" % ("0.1.0-"+v))
nraychaudhuri (19) [Avatar] Offline
#2
Re: sbt + code + web.xml
This is awesome. Thank you.

I am planning to upgrade all the codebase to Scala 2.9.x and SBT 0.10 or maybe 0.11.
globulon (18) [Avatar] Offline
#3
Re: sbt + code + web.xml
Thanks to some help of the guys on the SBT Google group I added the following to the previous settings in order to start/stop H2


object H2TaskManager {
var process: Option[Process] = None

val runH2 = TaskKey[Unit]("h2-run", "Runs h2")
val runH2Task = runH2 :={}

val stopH2 = TaskKey[Unit]("h2-stop", "Stops h2")
val stopH2Task = stopH2 :={
process match {
case None => println("Database already stopped"smilie
case Some(_) =>
println("Stopping database...")
process.foreach{_.destroy()}
process = None
println("Database stopped...")
}
}

def startDatabase(paths: Seq[String]) = {
process match {
case None =>
val cp = paths.mkString(System.getProperty("path.seperator"))
val command = "java -cp " + cp + " org.h2.tools.Server"
println("Starting Database with command: " + command)
process = Some(Process(command).run())
println("Database started ! ")
case Some(_) =>
println("H2 Database already started")
}
}
}

object MainBuild extends Build {
import Resolvers._
import Dependencies._
import BuildSettings._
import JettyDependencies._
import ScalazDependencies._
import DatabaseDependencies._
import H2TaskManager._

lazy val wekanban = Project(
"wekanban",
file("."),
settings = buildSettings ++ testDependencies ++ webSettings ++ Seq(stopH2Task) ++ Seq (
libraryDependencies ++= Seq(jettyServlet, jetty7, jettyServer, scalazCore, scalazHttp, h2, squeryl),
runH2 <<= (fullClasspath in Compile) map { cp =>
startDatabase(cp.map{_.data}.map{_.getAbsolutePath()}.filter{_.contains("h2database")})
}
)
)

}

Seems to work fine smilie
436204 (1) [Avatar] Offline
#4
Binary scam
<a href="http://www.bestbinaryoptionsrobots.com/" rel="nofollow">best binary robots</a>
<a href="http://www.bestbinaryoptionsrobots.com/" rel="nofollow">binary option auto traders</a>
<a href="http://www.bestbinaryoptionsrobots.com/" rel="nofollow">binary options softwares</a>