July 4, 2011
filed in the early afternoon by dr_who in: hacking
average time to read 1:12 minutes

the solution described below turns out to have its flaws and is not really recommended — have a look at the recently posted update for a better solution!

simple build tool 0.7.5 comprised the jetty and webapp functionality — version 0.10.0 (sbt10) no longer does so, instead you have to pull in the sbt webplugin. one feature of sbt7.5′s webapp support that we used heavily was the ability to run jetty out of the source tree instead of the exploded temporary WAR file:

> Another possibility is to directly run the web application out of the the source web application path: > > override def jettyWebappPath = webappPath > override def scanDirectories = mainCompilePath :: testCompilePath :: Nil > > — sbt7.5, continuous redeployment

(we actually used to set scanDirectories to Nil)

achieving the same setup with sbt10 is not as simple or even obvious, the solution reported in the simple build tool newgroups does not really provide the same feature, as it still requires to have a ~ prepare-webapp running in sbt. here’s what seems to work:

<pre language=”scala”> // run jetty from source tree jettyConfiguration <<= (sourceDirectory in Runtime, jettyConfiguration) map { (sourceDir, jettyConf) => { val conf = jettyConf.asInstanceOf[DefaultJettyConfiguration] new DefaultJettyConfiguration { def classpath = conf.classpath def jettyClasspath = conf.jettyClasspath def war = sourceDir / “webapp” def contextPath = conf.contextPath def classpathName = conf.classpathName def parentLoader = conf.parentLoader def scanDirectories = conf.scanDirectories def scanInterval = conf.scanInterval def port = conf.port def log = conf.log def jettyEnv = conf.jettyEnv def webDefaultXml = conf.webDefaultXml } } }
  // set jetty scan dirs to empty list jettyScanDirs := Nil </pre>

changes in src/main/webapp are immediately effective for the running jetty instance. voila!

p5rn7vb
all content posted on these pages is an expression of my own mind. my employer is welcome to share these opinions but then again he might not want to.

1 comment »

  1. [...] time to read 0:51 minutes it turns out that the sbt/web-plugin configuration i described in my last post is not quite cutting it. what we observed is that while changes to the contents of the webapp [...]

    pingback by xyzzy xyzzy… » sbt10, webplugin, jetty, run-in-place: once more… — July 22, 2011 @ 14:56

RSS feed for comments on this post. TrackBack URI

Leave a comment