Search code examples
scalamavenliftsbt

LIFT setup for web project: generate with mvn, and manage with sbt


I am new to LIFT, and I am trying to find a reliable instructions how to generate and manage LIFT web project with maven and sbt respectively. Can someone please direct me (or provide here) to the up to date instructions how to setup sbt for the maven generated project? From every post what I've red, it looks like the best setup for the LIFT projects: generate with mvn, manage with sbt. Will you agree? (I cannot generate LIFT/web project with sbt. Right? SBT is only good for managing it. Right? ) Every instructions I tried are out of date though. (I obviously can simply download and un-tar the archetype project, but I want to find a more fundamental approach for managing the environment ) Thanks.


Solution

  • While I'm using lift I don't need a maven at all, just SBT. So, it is very useful to read SBT Getting Started section. Also lift wiki contains some information. But be sure that you read material related to the proper SBT version. And finally, you can pay attention to my lift project template on github.
    Good Luck with Lift! It's awesome ;)

    By following question in you comment I put here some common config from my projects.
    So, that is ./project/build.scala as alternative to ./build.sbt

    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.yourorganization",
        version      := "0.1-SNAPSHOT",
        scalaVersion := "2.9.1")
    
      def yourWebSettings = webSettings ++ Seq(
        // If you are using jrebel
        scanDirectories in Compile := Nil
        )
    
      lazy val shade = Project(
        id = "project-name",
        base = file("."),
        settings = defaultSettings ++ yourWebSettings)
    
      lazy val defaultSettings = Defaults.defaultSettings ++ Seq(
        name := "project-name",
        resolvers ++= Seq(
          "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases", 
          "Java.net Maven2 Repository" at "http://download.java.net/maven/2/"),
    
        libraryDependencies ++= {
          val liftVersion = "2.4-M5"
          Seq(
            "net.liftweb" %% "lift-webkit" % liftVersion % "compile",
            "org.eclipse.jetty" % "jetty-webapp" % "7.5.4.v20111024" % "container",
            "org.squeryl" %% "squeryl" % "0.9.5-SNAPSHOT" % "compile",
            "ch.qos.logback" % "logback-classic" % "1.0.0" % "compile",
            "org.scalatest" %% "scalatest" % "1.6.1" % "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")
      )
    }
    

    ./project/build.properties

    #Project properties
    sbt.version=0.11.1
    

    ./project/plugins.sbt

    resolvers += Classpaths.typesafeResolver
    
    addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse" % "1.5.0")
    
    libraryDependencies <+= sbtVersion(v => "com.github.siasia" %% "xsbt-web-plugin" % (v+"-0.2.10"))
    

    Having these three files are enough to configure sbt.
    And of course you can run your application by calling container:start