diff --git a/MavLift/.DS_Store b/MavLift/.DS_Store index 6d6450171..cf270f223 100644 Binary files a/MavLift/.DS_Store and b/MavLift/.DS_Store differ diff --git a/MavLift/.gitignore b/MavLift/.gitignore new file mode 100644 index 000000000..54088d571 --- /dev/null +++ b/MavLift/.gitignore @@ -0,0 +1,2 @@ +target +.DS_Store diff --git a/MavLift/README b/MavLift/README index f15df41f4..058defbf8 100644 --- a/MavLift/README +++ b/MavLift/README @@ -1,12 +1,28 @@ This project contains some try outs so far. -The project is using Maven 2 as a build tool. See pom.xml for the dependancies. +The project is using sbt or Maven 2 as a build tool. See build.scala or pom.xml respectively for the dependencies. I used IntelliJ IDEA as my IDE. It has nice autocompletion. -To run, cd into the root directory (where this file is) and run: -mvn jetty:run +---- +To compile and run jetty, cd into the root directory (where this file is) and run: + +$ sbt +... +> compile +> ~;container:start; container:reload / + +(Note that you first have to start sbt and then on its console start jetty with the container:start task, otherwise it will exit immediately. More here: https://github.com/siasia/xsbt-web-plugin/wiki) + +In OS X, sbt can be installed with $ sudo port install sbt + +---- + + +Alternatively, maven can also be used: + +mvn jetty:run Note: You may need to add the pluginGroup to the $HOME/.m2/settings.xml @@ -21,6 +37,9 @@ Note: You may need to add the pluginGroup to the $HOME/.m2/settings.xml ... +---- + + To test one of the URL's use: curl http://localhost:8080/mongodb @@ -30,6 +49,9 @@ Other important files: SomeThing.scala - This file contains the URL routes (like urls.py) and my try outs- See serve case Req +---- + + I tried several approaches for scala talking to mongodb Lift Record: works for inserts and simple (inc geo) queries. but i couldn't figure out how to sort. diff --git a/MavLift/pom.xml b/MavLift/pom.xml index 98a49ff7c..96510ac45 100644 --- a/MavLift/pom.xml +++ b/MavLift/pom.xml @@ -34,11 +34,6 @@ Scala-Tools Dependencies Repository for Snapshots http://scala-tools.org/repo-snapshots - - - - - diff --git a/MavLift/project/build.properties b/MavLift/project/build.properties new file mode 100755 index 000000000..1fd04292d --- /dev/null +++ b/MavLift/project/build.properties @@ -0,0 +1,2 @@ +#Project properties +sbt.version=0.11.2 diff --git a/MavLift/project/build.scala b/MavLift/project/build.scala new file mode 100755 index 000000000..5946d8285 --- /dev/null +++ b/MavLift/project/build.scala @@ -0,0 +1,65 @@ +import sbt._ +import Keys._ +import com.github.siasia._ +import PluginKeys._ +import WebPlugin._ +import WebappPlugin._ + +object LiftProjectBuild extends Build { + override lazy val settings = super.settings ++ buildSettings + + lazy val buildSettings = Seq( + organization := "com.tesobe", + version := "0.1", + scalaVersion := "2.9.1") + + def yourWebSettings = webSettings ++ Seq( + // If you are use jrebel + scanDirectories in Compile := Nil + ) + + lazy val opanBank = Project( + "OpanBank", + base = file("."), + settings = defaultSettings ++ yourWebSettings) + + lazy val defaultSettings = Defaults.defaultSettings ++ Seq( + name := "Opan Bank", + resolvers ++= Seq( + "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases", + "Java.net Maven2 Repository" at "http://download.java.net/maven/2/", + "Scala-Tools Dependencies Repository for Releases" at "http://scala-tools.org/repo-releases", + "Scala-Tools Dependencies Repository for Snapshots" at "http://scala-tools.org/repo-snapshots"), + + libraryDependencies ++= { + val liftVersion = "2.4" + Seq( + //%% means: add current scala version to artifact name + + "net.liftweb" %% "lift-webkit" % liftVersion % "compile", + "net.liftweb" %% "lift-mapper" % liftVersion % "compile", + "net.liftweb" %% "lift-mongodb" % liftVersion % "compile", + "net.liftweb" %% "lift-mongodb-record" % liftVersion % "compile", + "net.liftweb" %% "lift-widgets" % liftVersion % "compile", +// "org.eclipse.jetty" % "jetty-webapp" % "7.5.4.v20111024" % "container", +// "org.eclipse.jetty" % "jetty-webapp" % "8.0.4.v20111024" % "container", + "org.mortbay.jetty" % "jetty" % "6.1.22" % "container", + "javax.servlet" % "servlet-api" % "2.5" % "provided->default", + "ch.qos.logback" % "logback-classic" % "1.0.0" % "compile", + "com.h2database" % "h2" % "1.2.138" % "runtime", + "com.mongodb.casbah" %% "casbah" % "2.1.5-1" % "compile", + "org.scalatest" %% "scalatest" % "1.6.1" % "test", + "org.scala-tools.testing" %% "specs" % "1.6.9" % "test", + "junit" % "junit" % "4.10" % "test") + }, + + // compile options + scalacOptions ++= Seq("-encoding", "UTF-8", "-deprecation", "-unchecked"), + javacOptions ++= Seq("-Xlint:unchecked", "-Xlint:deprecation"), + + // show full stack traces + testOptions in Test += Tests.Argument("-oF") + ) + +} + diff --git a/MavLift/project/plugins.sbt b/MavLift/project/plugins.sbt new file mode 100755 index 000000000..5f5998f1a --- /dev/null +++ b/MavLift/project/plugins.sbt @@ -0,0 +1,14 @@ +resolvers += Classpaths.typesafeResolver + +// addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse" % "1.5.0") + +// resolvers += "sbt-deploy-repo" at "http://reaktor.github.com/sbt-deploy/maven" +// addSbtPlugin("fi.reaktor" %% "sbt-deploy" % "0.3.1-SNAPSHOT") + +resolvers += "Web plugin repo" at "http://siasia.github.com/maven2" + +libraryDependencies <+= sbtVersion(v => v match { +case "0.11.0" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.0-0.2.8" +case "0.11.1" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.1-0.2.10" +case "0.11.2" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.2-0.2.11" +}) \ No newline at end of file