Site-wide Tags:  Linux(17) | CommandLine(12) | Ubuntu(10) | RemoteAccess(7) | Tools(7) | Vim(7) | LiftWeb(5) | SBT(5) | SoftwareDev(5) | Mac(5) | Scripts(4) | WebDev(4) | Diagrams(4) | Lifty(3) | NetworkDrives(3) | Processwire(3) | Security(3) | Fog(3) | VCS(3) | BestPractices(3) | RaspberryPi(2) | WebDesign(2) | Encryption(2) | Windows(2) | SSH(2) | WinCommandPrompt(2) | GitHubRepos(2) | Emacs(2) | PHP(2) | IDE(2) | ErrorMsgs(2) | JVM(2) | Hardware(2) | Bash(2) | Networks(2) | Graphviz(2) | Cloning | Cygwin | Graphics | Java | SystemRecovery | lessc | Maven | Python | PXE | Samba | LXDE | PackageManagement | LifeHacks | LESS |

This site has been archived and will no longer be updated.
You can find my new homepage at neilpahl.com.

Entry 2: Configuring SBT for Lift

Topic: Lift   

Tags:  LiftWeb   SBT   

Created on Thu, 14 Jun 2012.

First, your going to need to install sbt. you can use your package manager like "apt-get install sbt", but last time it gave me the older version. I followed the unix instructions:

Download sbt-launch.jar and place it in ~/bin.

Create a script to run the jar, by placing this in a file called sbt in your ~/bin directory:

java -Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=384M -jar `dirname $0`/sbt-launch.jar "$@"

Make the script executable:

$ chmod u+x ~/bin/sbt

Then, going through the process of figuring out sbt for the second time, I realized its actually quite easy if you follow the instructions they have on assembla. The first time was confusing because they give instructions for the outdated version (which has a higher version number [0.7 > 0.10] when .10 is actually newer)

Lift documentation seems to be trying to catch up to the switch from sbt 0.7 to 0.10 (i still dont get why .1 is new than .7 since .7 is clearly greater than .1, is it normal to have .10 meaning "point ten"?) but the the using sbt section of assembla provided a good starting point.


Basically, create a folder for a project with a build.sbt in the root, then a projectName/project/plugins.sbt containing the following which is now being suggested by the documentation:

build.sbt

name := "projname"
 
scalaVersion := "2.9.1"
 
seq(webSettings: _*)

// If using JRebel with 0.1.0 of the sbt web plugin
//jettyScanDirs := Nil
// using 0.2.4+ of the sbt web plugin
scanDirectories in Compile := Nil

//resolvers += "Java.net Maven2 Repository" at "http://download.java.net/maven/2/"

// you can also add multiple repositories at the same time
resolvers ++= Seq(
  "Scala Tools Releases" at "http://scala-tools.org/repo-releases/",
  "Java.net Maven2 Repository" at "http://download.java.net/maven/2/"
)

// if you have issues pulling dependencies from the scala-tools repositories (checksums don't match), you can disable checksums
//checksums := Nil

libraryDependencies ++= {
  val liftVersion = "2.4" // Put the current/latest lift version here
  Seq(
    "net.liftweb" %% "lift-webkit" % liftVersion % "compile->default",
    "net.liftweb" %% "lift-mapper" % liftVersion % "compile->default",
    "net.liftweb" %% "lift-wizard" % liftVersion % "compile->default")
}

// when using the sbt web app plugin 0.2.4+, use "container" instead of "jetty" for the context
// Customize any further dependencies as desired
libraryDependencies ++= Seq(
  "org.eclipse.jetty" % "jetty-webapp" % "8.0.4.v20111024" % "container", // For Jetty 8
  //"org.eclipse.jetty" % "jetty-webapp" % "7.3.0.v20110203" % "container", // For Jetty 7
  //"org.mortbay.jetty" % "jetty" % "6.1.22" % "jetty,test", // For Jetty 6, add scope test to make jetty avl. for tests
  "org.scala-tools.testing" % "specs_2.9.0" % "1.6.8" % "test", // For specs.org tests
  "junit" % "junit" % "4.8" % "test->default", // For JUnit 4 testing
  "javax.servlet" % "servlet-api" % "2.5" % "provided->default",
  "com.h2database" % "h2" % "1.2.138", // In-process database, useful for development systems
  "ch.qos.logback" % "logback-classic" % "0.9.26" % "compile->default" // Logging
)

// by default, it listens on port 8080; use the following to override
port in container.Configuration := 8081

in the project/plugins.sbt put:

libraryDependencies <+= sbtVersion(v => "com.github.siasia" %% "xsbt-web-plugin" % (v+"-0.2.10")) // moved to repo1
// for the older version of the plugin, use the following instead:
// you will need to change jetty's scope from 'container' to 'jetty' above
//libraryDependencies <+= sbtVersion(v => "com.github.siasia" %% "xsbt-web-plugin" % ("0.1.0-"+v))

then put your scala files in ../projectRoot/src/main/scala, and web template files in ../projectRoot/src/main/webapp


I used this configuration to work through the chat tutorial on the liftweb.net

Another option to quickly get your lift app going is to use lifty. this sbt plugin will create a lift app according to a certain recipe which you can use their sample or define your own. It worked quite well and I had their sample webapp runnign in no time.

However, as a newcomer it didn't help me much because althoguh it put all the code in, I wasn't quite sure what it was doing. I think I prefer manualy setting up my lift project and will use lifty later on when I get a better clue. Hopefully learing to define my own recipes will be easy enough.

Now to learn the fundamentals of lift...



PLEASE let me know if I'm doing something wrong, or if you have any suggestions or requests~

blog comments powered by Disqus

All Entries Within This Topic:

Subscribe to this topic:

Browse Topics: