Fork me on GitHub

FAQ

A trick is missing ? Just open an issue, and even better fork the project, improve the documentation and send a pull request.

My IDE is complaining about missing classes (views, routes...)

Missing view in Play 2 Controller

Play 2 is generating a couple of classes (views, routes...) that your code is using such as routes and views. To make your IDE more happy, add target/scala-2.9.1/src_managed/main/ as a source folder. Be careful to not modify such sources, as they will be regenerated during the next compilation.

If you're using IDE's Maven support, you can use the build-helper-maven-plugin to add this source folder automatically:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <version>1.7</version>
    <executions>
        <execution>
            <id>play2-add-managed-sources</id>
            <goals>
                <goal>add-source</goal>
            </goals>
            <configuration>
                <sources>
                    <source>
                    ${project.build.directory}/scala-2.9.1/src_managed/main
                    </source>
                </sources>
            </configuration>
        </execution>
    </executions>
</plugin>

My Homebrew installation from play 2 does not work

When PLAY2_HOME is using a homebrew play 2 installation, you get:

[INFO] --- play2-maven-plugin:1.2.0-SNAPSHOT:compile (default-compile) @ play2-authenticitytoken-sample ---
/usr/local/Cellar/play/2.0/libexec/play: line 51: /usr/local/Cellar/play/2.0/libexec//usr/local/Cellar/play/2.0/
libexec/../libexec/framework/build: No such file or directory

The problem comes from the homebrew installation of play using relative directories. The versions 1.2.0+ of the play2-maven-plugin manages this issue by using directly the play 2 executable from "/usr/local/bin/play"

How do I keep in sync my SBT Metadata and my Maven metadata ?

For each play invocations, the plugin build an environment containing the Maven metadata such as:

  • project.groupId : the Maven group Id
  • project.artifactId : the Maven artifact Id
  • project.version : the Maven version
  • all other Maven properties

So, to keep your version in sync, you need to edit your project/Build.scala file and add:

def fromEnv(name: String) = System.getenv(name) match {
  case null => None
  case value => Some(value)
}
val appName = fromEnv("project.artifactId").getOrElse("my-app")
val appVersion = fromEnv("project.version").getOrElse("1.0-SNAPSHOT")
// ...

Check this page for more information.