Friday, November 8, 2013

Since the support for building a war is not available for play application after Play 2.1.4, there is a workaround which can help you get over this problem. Follow the following steps very carefully :-

1. Create Build.scala (can be copied from earlier versions of play application). 

// dont use this file to run project - use build.sbt (only to create a war)
(Comment this file when running the application)
import sbt._
import Keys._
import play.Project._
import com.github.play2war.plugin._

object ApplicationBuild extends Build {

  val appName         = "Test_App"
  val appVersion      = "1.0-SNAPSHOT"

  val appDependencies = Seq(
    // Add your project dependencies here,


  val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA)
  .settings(Play2WarPlugin.play2WarSettings: _*)

 Play2WarKeys.servletVersion := "3.0"


2. Comment all the lines from build.sbt (originally available in project) (Make sure to uncomment when you want to run the application)

3. Make changes according to following sample in plugins.sbt :-

// For running project, comment at the time of making war.
addSbtPlugin("" % "sbt-plugin" % "2.2.0")

// WARNING: only for making the war
//addSbtPlugin("play" % "sbt-plugin" % "2.1.3")

//addSbtPlugin("com.github.play2war" % "play2-war-plugin" % "1.0")

4. make the following change in
//for running application

// Only for making the war

After making the following changes, just run "play war" and BAM, war is generated and deploy it to get set go.

P.S. :- Roll back the changes to original settings to run the application. Dont use play scala after making the changes. It may ruin the project.