James Williams
LinkedInMastodonGithub

Creating a PlayN Project

Maven uses objects called archetypes to describe the how to create a project. They are useful because they help new users adhere to the project format contract as set by the project's creators. While Maven does have some expected defaults (listed below), you are free to make an archetype with non-standard file paths.

Maven General File Structure

Path Description
pom.xml Describes how to build the project
src/main/ Source code
src/main/resources Resources required by that language's source
src/test/ Test source code
src/test/resources Resources required by the test files

Each of the targets may also include files that are platform-specific. For example, Android includes a AndroidManifest.xml file that provides metadata about the application, a ProGuard configuration file to assist in obfuscating code, and an Android-specific resource directory. To create a new PlayN application, run the command:

    mvn archetype:generate -DarchetypeGroupId=com.googlecode.playn -DarchetypeArtifactId=playn-archetype -DarchetypeVersion=1.3.1

If this is the first time it has run, it will connect to Maven's central repositories and download all the needed dependencies. It will also ask you for some data about your application before generating the files. At the time of writing, the most current version is 1.3.1. Update the archetype version if this is no longer the case.

We can use the following commands to run our newly created project as a Java, HTML5, or Android app. For Android, you need to have a connected device in development mode or a running emulator.

Running the application

Platform Maven Command Ant Command
Java mvn test ant run-java
HTML mvn -Phtml integration-test ant run-html
Android mvn -Pandroid install

Sorry for the short post today. Am feeling a bit under the weather. :(