Skip to main content

How to mavenify a Play 2 application

This article is for developers who want to develop web-apps with Play 2 Framework but are required to integrate these new web-apps in an existing build process based on Maven.

Lucky you, someone already started a project to do this: play2-maven-plugin.
Unfortunately, this Maven plugin does not support hot reloading yet, which makes the development process painful.

To make it short, you still need SBT to enjoy Play 2 hot reloading feature... but you do not want to have to maintain both Maven and SBT configurations.
The trick is to configure SBT from Maven pom files with sbt-pom-reader.

This is how you need to configure your play2-maven project:
<my-maven-project>/
  pom.xml                  <- Your maven build
  build.sbt                <- the sbt Play 2 configuration
  project/
     build.properties      <- the sbt version specification
     build.scala           <- the sbt build definition
     plugins.sbt           <- the sbt plugin configuration

  ..                       <- Whatever files are normally in your maven project.

Each of the files should have the following contents.
pom.xml: @see play2-maven-plugin usage

build.sbt:
play.Project.playJavaSettings //or play.Project.playScalaSettings

project/build.properties:
sbt.version=0.13.0

project/build.scala:
object BuildFromMavenPomSettings extends com.typesafe.sbt.pom.PomBuild

project/plugins.sbt:
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.1")

addSbtPlugin("com.typesafe.sbt" % "sbt-pom-reader" % "1.0.1")


Now you can use Maven to build your Play 2 application and SBT to develop it with hot reloading. 

Happy coding!

Source: https://github.com/sbt/sbt/issues/1123

Comments

Popular posts from this blog

Transferring SMS from iPhone to Android (for developers)

I recently bought a Nexus 4 to replace my old iPhone 3GS. The transition has been smooth except for the transfer of the SMS from iPhone to Android which led me to write some code and this post. The most interesting article I found on this subject was  iPhone SMS to Android Converter . Considering iSMS2droid has not been updated since October 2011 and does not seem to be compatible with iOS 6, if you choose this solution, you will have to upload your messages on  Jan Grewe  server. You decide for yourself if you are OK with sending your SMS database to his server. I chose to follow another path. After failing to find iSMS2droid or SMS Backup & Restore source code I started coding my own  SMS transfer application . Limitations Only works with iOS 6 SMS Only works with Android having the  sms://  content provider Does not handle attachments yet Requires  Android SDK  to build the Android app Step 1: Find your iPhone SMS...

About Estimation

Recycling an article I wrote in French in 2010 . Following endless estimation sessions in the project I am working on, I have come to ask myself some questions about this practice. Why do we estimate? I think an estimation session should have two purposes. To share a common understanding of upcoming stories. To estimate upcoming work in order to plan the next steps and monitor the evolution of the project. Who should attend the estimation session? Anyone who can clarify upcoming stories and anyone who will carry these stories to completion. To improve your estimation session, you can try the following: divide the estimation session into two stages . Understanding upcoming stories. Estimating the work to be done. Understanding upcoming stories through discussion among project participants is the highlight of an estimation session . The shared vision emerging from these exchanges will facilitate future communications. Estimating should be more relevant and should be d...

TransferWise: tiny discrepancy when sending money to Colombia

I recently used TransferWise to send GBP to COP and I have been surprised by a tiny discrepancy, 11 COP (~0.0022 GBP), between the amount the recipient received and what TransferWise advertised he would receive. TransferWise support team explained me this difference as follow: When sending from GBP to COP, we receive GBP from your side and we convert the amount to COP with the mid market rate. However our partner in Colombia needs to receive USD from us, so we convert the amount in COP to USD with the rate our partner gives us. We send them those USD and then they convert them to COP and send them to the recipient. In your case what happen was the following: You sent us 1,000 GBP, we took our fee and convert 974.43GBP to COP with the mid market rate at that moment: 1 GBP = 4,970.50 COP. So that was 4,843,404.315 COP, however in COP there’s no cents so it got rounded down to 4,843,404 COP. After that we converted to USD since our partner need to receive USD from us. The ...