Tuesday, January 15, 2013

Play Framework 2.0.3 to 2.1 RC2 upgrade

If you were expecting that upgrading your Play project from 2.0.x to 2.1 will be a simple replacement of the play libraries you will be disappointed. But don't worry, as it is not that bad. Here is a mini guide for the upgrade.

  1. Download Play Framework 2.1RC2.
  2. Edit [yourApp]/project/plugins.sbt file and set SBT version to "2.1-RC2"
  3. Edit [yourApp]/project/build.properties file and set SBT version to “0.12.2-RC2”
  4. The [yourApp]/project/Build.scala file needs to be updated to remove a warning about “using a deprecated version of Play's SBT Project”. To do this you will need to: 
    1. Replace “import PlayProject._with “import play.Project._
    2. Update appDependencies object value and make sure the sequence contains "javaCore, javaJdbc, javaEbean".
      Example:
      val appDependencies = Seq(javaCore, javaJdbc, javaEbean)
    3. Replace
      val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA)” 
      with
      val main = play.Project(appName, appVersion, appDependencies)
  5. 1.       It is recommended to run “play clean-all” before compiling anything. This will ensure a cleanup of sbt.
  6. A change in the API that will likely impact every application out there is in how you access the form. Every reference to Controller.form() will error as that is no longer available. Instead you should change your code to use play.data.Form.form().
  7. Launch the play console and try and compile the application. You might get new warnings regarding your routes. They are just warnings but you should have a look at them.
  8. If your code compiles and you are using Eclipse as your IDE of choice you should re-eclipsify your project as Play 2.1 will have a different classpath and a different set of libraries. Note that the old "eclipsify" command is no longer available as it was replaced by "eclipse" command.
If you are wondering about differences regarding classpath, tasks, commands between 2.0.3 and 2.1 RCs you can have a look here.

No comments: