Skip to content
This repository was archived by the owner on Apr 4, 2026. It is now read-only.

Configuration

dlecan edited this page Jan 12, 2013 · 39 revisions

In the next descriptions, APP_HOME is the root of your Play 2.0 application you want to package as a WAR file.

Add play2war plugin

In APP_HOME/project/plugins.sbt, add:

resolvers += "Play2war plugins release" at "http://repository-play-war.forge.cloudbees.com/release/"

addSbtPlugin("com.github.play2war" % "play2-war-plugin" % "0.9-RC1")

Import Play2War SBT settings

In APP_HOME/project/Build.scala, add:

...
import PlayProject._
import com.github.play2war.plugin._

Configure servlet container version and add all Play2war settings in your project configuration

val appVersion      = "1.0-SNAPSHOT"
...
val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(
  // ... Your own settings here
  Play2WarKeys.servletVersion := "3.0"
  // Or Play2WarKeys.servletVersion := "2.5"
).settings(Play2WarPlugin.play2WarSettings: _*)

Configure logging

You probably need to override default Play 2.0 logging configuration because:

  • An external file will be written in $USER_HOME/logs/...

  • STDOUT appender pattern can be improved

Create a file APP_HOME/conf/logger.xml with the following content :

<configuration>
    
  <conversionRule conversionWord="coloredLevel" converterClass="play.api.Logger$ColoredLevel" />

  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <pattern>%date - [%level] - from %logger in %thread %n%message%n%xException%n</pattern>
    </encoder>
  </appender>
  
  <logger name="play" level="INFO" />
  <logger name="application" level="INFO" />
  
  <!-- Off these ones as they are annoying, and anyway we manage configuration ourself -->
  <logger name="com.avaje.ebean.config.PropertyMapLoader" level="OFF" />
  <logger name="com.avaje.ebeaninternal.server.core.XmlConfigLoader" level="OFF" />
  <logger name="com.avaje.ebeaninternal.server.lib.BackgroundThread" level="OFF" />

  <root level="ERROR">
    <appender-ref ref="STDOUT" />
  </root>
  
</configuration>

Embed custom WAR configuration files

You can embed custom WAR configuration files, such as MANIFEST.MF, web.xml, ... For this, copy then in your APP_HOME/war folder. Don't forget to add subfolders !

Samples:

  • APP_HOME/war/myfile.txt will result in app_home.war!/myfile
  • APP_HOME/war/META-INF/MANIFEST.MF will result in app_home.war!/META-INF/MANIFEST.MF
  • APP_HOME/war/WEB-INF/web.xml will result in app_home.war!/WEB-INF/web.xml

Clone this wiki locally