Sunday, December 25, 2011

SBT 0.11.x Web plugin

After moving from SBT 0.7.x to 0.10.x, I wasn't able to run any of my web applications on SBT. After searching the web and SBT mail list I found which might be the only solution out there. However simply following the instructions on the Getting Started, I wasn't able to install the plugin successfully. But here is basically how it should be done, just like describe on the site.

Add the following to "project/plugin.sbt"
sbtVersion(v => "com.github.siasia" %% "xsbt-web-plugin" % (v+"-0.2.10"))
Then the following to build.sbt
seq(webSettings :_*)

libraryDependencies += "org.mortbay.jetty" % "jetty" % "6.1.22" % "container"

Here is a few things to be careful of.
for plugin.sbt

  1. you actually need this line before the sbtVersion declaration
    resolvers += "Web plugin repo" at ""
  2. the variable "v" inside sbtVersion is the version of you SBT, so for the time I tried to install it was 0.10.0. It actually caused problem which says the library of version 0.10.0-0.2.10 could not be found on any repository I defined.
for build.sbt
  1. just make sure the jetty is included as "container" and not anything else, ie "compile" or "test"

After some more searching I realized one thing. The plugin only has the newest version and only with the most updated or whichever version it chooses of SBT in its github repository. If you try to test out the maven URL with guessing versions, you will get page not exists response if the version you want does not exists on server, so you can't even browse a list to see which version of SBT it supports and what the most updated version is. Due to this lack of backward support of the web-plugin, I was forced to move to 0.11.2. After the update, I had to upgrade my eclipse plugin. For which, I was luck that the SBT Eclipse plugin has an upgraded version for the new SBT. Since I only had the Eclipse plugin and no other plugin, I could work as normal after upgrade my plugin.