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>
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"
For each play invocations, the plugin build an environment containing the Maven metadata such as:
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.
With Play 2.0.4+, the Maven build is not marked as failing if the compilation or the tests fails. The issue comes from the play.bat
file that does not return a valid error code. To overcome this problem you have to update play.bat file replacing last line:
endlocal
with
exit /b %errorlevel%
endlocal
Cloudbee provides a great service to do continuous integration. However, using the plugin on a Maven build on Cloudbee, you are going to encounter two issues
To fix the issue, add a build step (pre steps) before Maven build step executing a shell command:
# Install play 2.0.4
mvn de.akquinet.innovation.play2:play2-maven-plugin:install-play -Dplay2version=2.0.4 -Dplay2basedir=${HOME}/opt
# Configure SBT to find javac
mkdir -p ~/.sbt
echo "javaHome := Some(file(\"`echo $JAVA_HOME`\"))" > ~/.sbt/global.sbt
cat ~/.sbt/global.sbt
Adjust the first command with the Play version you want. The play installation step does not reinstall the framework if it is already installed.
Then you must instruct Maven to find the right Play version. In the Goals and Options textbox write:
clean install -DPLAY2_HOME=${HOME}/opt/play-2.0.4
Again, don't forget to update the play version with the version you chose in the script.
The final configuration should be like: