Binding Lift's run mode to GAE's Environment

Lift supports run modes, a feature which makes it easy to tweak the application depending on its environment. This is useful for enabling/disabling features, changing things like a system's sending email account, rendering a google analytics javascript block, et cetera. In Lift this mode is dictated by the run.mode system property which, in some environments, can be a bit painful to change.

For App Engine, however, there is a simple solution: bind Lift's mode directly to the GAE environment:

package bootstrap.liftweb

class Boot {
  def boot {
    
    System.setProperty("run.mode",
      System.getProperty("com.google.appengine.runtime.environment"))
      // the rest of your configuration... 

  }
}

GAE supports local development through a local server, complete with working and faux services. Using appengine-web.xml you can configure system properties, but there isn't a simple way to vary these settings according to the GAE environment (perhaps a resources plugin for sbt is in order...).

However, GAE, like Lift, identifies its environment using a system property. Incidentally, the two settings it uses align with Lift's run modes: Production and Development.