Thursday, February 7, 2013

Play 2.0.x Module

During development one always finds themselves in the position of creating reusable code. For Play, I have a project containing a lot of the boilerplate code that I want to share among many concrete Play applications. One solution is to create a regular Play project (I'll refer to it as "playcommons") and set-up project dependency between your application and  the playcommons project. See here for more details. However, managing the versions of the playcommons is not straight-forward.
Another solution is to make the playcommons project a Play module. This way, the project can be compiled and published and therefore the versions will be managed via the repository. I did not find some clear documentation on Play website on creating modules but here is a good article on the subject: http://www.objectify.be/wordpress/?p=363.
In the end, you can either get the packaged jar of the module and include it in the Play application (this way you don't have to manage a repository) or publish the module in a repository and then manage the dependency via Ivy in Build.scala.