Play Framework: How to change play default packages?

According to the current Play 2.0 documentation, this is now possible:

Note that in Play 2.0, the controllers, models and views package name conventions are now just that and can be changed if needed (such as prefixing everything with com.yourcompany).

This works well for an empty Play application, there are however some details to take note of for anything else:

  1. Importing custom namespaces into view templates will work for any types except for those that are declared in the first line of a template, which are the arguments for the scala render function that is generated out of a view. Our workaround is to add the full package name to type declarations in the first line of view templates.
  2. For every namespace defined in the routes file (e.g. a custom package and the default package for the Assets route), Play 2.0 generates a corresponding routes source file within the same namespace, so you need to take care to address the correct file when e.g. doing redirection.

Leave a Comment