Dev/maven

Firebase and Maven
NB: From the release of Firebase 1.8.0, the group id of the Firebase archetypes have changed from "com.cubeia.tools" to "com.cubeia.firebase.tools" and the archetype version 1.8.0 matches the Firebase version 1.8.0.

Requirements
This quick start assumes a recent Linux System with Java 1.6 or higher installed. You will also need Maven 2.2.1 or higher installed.

Adding the Cubeia Repository
In order to use the Cubeia Firebase artifacts and archetypes you need to add the Cubeia Nexus maven repository to your maven settings.

cubeia-nexus http://m2.cubeia.com/nexus/content/groups/public true true

Creating New Projects
Firebase comes with 4 different archetypes that can be used to create new projects. These are:


 * "firebase-game-archetype" - This creates a maven project for a Game Archive (GAR).
 * "firebase-service-archetype" - This creates a maven project for a Service Archive (SAR).
 * "firebase-tournament-archetype" - This creates a maven project for a Tournament Archive (TAR).
 * "firebase-flex-archetype" - A flex client archetype (SWF).

All the above archetypes are in the "com.cubeia.firebase.tools" group, the current version is 1.9, and you will probably need to point maven to the right repository http://m2.cubeia.com/nexus/content/groups/public.

So to create a new game project, for example, you can execute the following.

mvn archetype:generate \ -DarchetypeGroupId=com.cubeia.firebase.tools \ -DarchetypeArtifactId=firebase-game-archetype \ -DarchetypeVersion=1.9 \ -DarchetypeRepository=http://m2.cubeia.com/nexus/content/groups/public

The generation will ask you for some of the following properties:


 * "groupId" - This is the maven build group id of the new artifact.
 * "artifactId" - The maven build artifact id.
 * "version" - Maven build version, defaults to 1.0-SNAPSHOT
 * "package" - Package for Java or Flex builds
 * "gameId" - The ID of the server game, asked for by the Flex and the Game archetypes

Packaging
If the project is created using an archetype as above, packaging is already configured. Otherwise, you need to first add a build plugin to you POM file. The current version is 1.10

com.cubeia.tools archive-plugin 1.10      true

Firebase comes with 4 different packaging types:


 * "firebase-gar" - Firebase Game Archive
 * "firebase-sar" - Firebase Service Archive
 * "firebase-tar" - Firebase Tournament Archive
 * "firebase-uar" - Fireabse Unified Archive

Given this, a complete POM for a game ("firebase-gar") may look like this:

 4.0.0 com.my-company.test funkyGame firebase-gar Funky Game 1.0-SNAPSHOT

com.cubeia.firebase firebase-api</artifactId> 1.9.0-CE provided log4j</groupId> log4j</artifactId> 1.2.14        com.cubeia.tools</groupId> archive-plugin</artifactId> 1.8.0-CE true

Running Firebase
If you're standing with a command line within a Firebase GAR, SAR, TAR och UAR project you can run Firebase via the command line. First add the following build plugin:

com.cubeia.tools</groupId> firebase-maven-plugin</artifactId> 1.9.0-CE

The run you module with this command:

mvn clean package firebase:run

By default dependencies of Firebase archives with scope provided will be included in the Firebase instance. Only direct dependencies are included. You can turn this off by adding <tt><includeProvidedArchives>false</includeProvidedArchives></tt> to the configuration section.

You can of course ommit the "clean package" from the command line above, but "package" needs to be run at least once before "firebase:run" is called.

Full plugin configuration with default values
com.cubeia.tools</groupId> firebase-maven-plugin</artifactId> 1.9.0-CE <overlaysEnabled>true</overlaysEnabled>

<overlaySourceDirectory>${basedir}/src/test/resources/firebase</overlaySourceDirectory>

<includeProvidedArchives>true</includeProvidedArchives> <deleteOnExit>true</deleteOnExit>

Running Firebase With A Game And Multiple Services
A common use case is that you will not only have your game deployed, but also any number of services. The services typically provide wrapper implementation towards your external systems (user database, wallet etc). It is also common that you want to provide local mocked versions of these services to facilitate easier starting and testing of the game server locally for developers.

Games and service archives that are declared as dependencies but with scope=provided will be copied to the /game/deploy folder of the Firebase instance that will be started, i.e. they will be deployed outside and in parallel to the current archive.

Below are some snippets from a pom.xml that will deploy a mock wallet service in parallel to the current archive (example is taken from our Poker):

com.cubeia.games</groupId> poker-game</artifactId> firebase-gar

com.cubeia.network.wallet.firebase</groupId> mock-wallet-service</artifactId> 1.2.3        firebase-sar provided