Before starting, be sure to have the play executable available from your PATH or to have defined the PLAY2_HOME system variable used by the plugin to find the Play 2 SDK. The packaging of your project must be play2.
export PLAY2_HOME=...
# or
mvn clean install -DPLAY2_HOME=...
# or if play is available in your path
mvn clean install
It is also possible to defined this location form the pom file directly (see below).
Best practice is to define the version of the Play2 plugin that you want to use in either your pom.xml or a parent pom.xml.
<project>
[...]
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>de.akquinet.innovation.play2</groupId>
<artifactId>play2-maven-plugin</artifactId>
<version>1.2.2-SNAPSHOT</version>
</plugin>
</plugins>
</pluginManagement>
</build>
[...]
</project>
To use the play2-maven-plugin Plugin, you need to add the following configuration to your pom.xml
<project>
[...]
<packaging>play2</packaging>
[...]
<build>
<plugins>
<plugin>
<groupId>de.akquinet.innovation.play2</groupId>
<artifactId>play2-maven-plugin</artifactId>
<version>1.2.2-SNAPSHOT</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
[...]
</project>
The play2-maven-plugin Plugin is invoked during the:
A full run, executing all the above steps:
mvn clean install
The PLAY2 location can also be defined in the pom.xml file such as in:
<plugin>
<groupId>de.akquinet.innovation.play2</groupId>
<artifactId>play2-maven-plugin</artifactId>
<version>1.2.2-SNAPSHOT</version>
<extensions>true</extensions>
<configuration>
<play2Home>some/path/to/play-2.0</play2Home>
</configuration>
</plugin>
The plugin is checking in this order:
If PLAY2_HOME is not defined, the plugin is looking inside the system PATH to find the play executable.
By default the plugin generates two packages: a jar containing the application and a zip embedding all required files to run the application. For Play 2 modules this second packages is useless, so you can disable it using:
<project>
[...]
<packaging>play2</packaging>
[...]
<build>
<plugins>
<plugin>
<groupId>de.akquinet.innovation.play2</groupId>
<artifactId>play2-maven-plugin</artifactId>
<version>1.2.2-SNAPSHOT</version>
<extensions>true</extensions>
<configuration>
<buildDist>false</buildDist>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
You can set the packaging classifier, applied to both packages (jar and zip):
<project>
[...]
<packaging>play2</packaging>
[...]
<build>
<plugins>
<plugin>
<groupId>de.akquinet.innovation.play2</groupId>
<artifactId>play2-maven-plugin</artifactId>
<version>1.2.2-SNAPSHOT</version>
<extensions>true</extensions>
<configuration>
<classifier>my-classifier</classifier>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
You can set additional files to be appended to the play framework distribution zip file. This is done after the zip file has been generated. All additional files are added to the top-level directory of the zip file (at the same level as the ./lib and start script).
<project>
[...]
<packaging>play2</packaging>
[...]
<build>
<plugins>
<plugin>
<groupId>de.akquinet.innovation.play2</groupId>
<artifactId>play2-maven-plugin</artifactId>
<version>1.2.2-SNAPSHOT</version>
<extensions>true</extensions>
<configuration>
<additionalFiles>
<additionalFile>${basedir}/your-start-script</additionalFile>
</additionalFiles>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
You can use the install-play goal to download and install Play 2 distributions.
On your prompt type;
mvn de.akquinet.innovation.play2:play2-maven-plugin:install-play -Dplay2version=2.1.0 -Dplay2basedir=${HOME}/opt
to install Play 2.1.0 in ${HOME}/opt/play-2.1.0.
Or register the install-play goal in your pom.xml and use the installed distribution through the plugin by adding;
<project>
[...]
<properties>
[...]
<play2.version>2.1.0</play2.version>
[...]
</properties>
[...]
<build>
<plugins>
[...]
<plugin>
<groupId>de.akquinet.innovation.play2</groupId>
<artifactId>play2-maven-plugin</artifactId>
<version>1.2.2-SNAPSHOT</version>
<extensions>true<extensions>
<configuration>
<play2Home>${user.home}/opt/play-${play2.version}</play2Home>
</configuration>
<executions>
<execution>
<id>play-installation</id>
<goals>
<goal>install-play</goal>
</goals>
<phase>pre-clean</phase>
<configuration>
<play2version>${play2.version}</play2version>
<play2basedir>${user.home}/opt</play2basedir>
</configuration>
</execution>
</executions>
</plugin>
[...]
</plugins>
</build>
[...]
</project>
The Maven process must be able to write and execute into play2basedir. If the requested version is already installed nothing gets downloaded.
<project>
[...]
<packaging>play2</packaging>
[...]
<build>
<plugins>
<plugin>
<groupId>de.akquinet.innovation.play2</groupId>
<artifactId>play2-maven-plugin</artifactId>
<version>1.2.2-SNAPSHOT</version>
<extensions>true</extensions>
<configuration>
<play2SystemProperties>
<property><name>hello</name><value>world</value></property>
<property><name>javax.net.debug</name><value>ssl</value></property>
</play2SystemProperties>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>