Dev/maven

From CubeiaWiki

Jump to: navigation, search

Contents

Firebase and Maven

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.

<repository>
  <id>cubeia-nexus</id>
  <url>http://m2.cubeia.com/nexus/content/groups/public</url>
  <releases>
    <enabled>true</enabled>
  </releases>
  <snapshots>
    <enabled>true</enabled>
  </snapshots>
</repository>

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.tools group, the current version is 1.7.0, 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.tools \
      -DarchetypeArtifactId=firebase-game-archetype \ 
      -DarchetypeVersion=1.7.0 \
      -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. Again the current version is 1.7.0

<build>
  <plugins>
    <plugin>
      <groupId>com.cubeia.tools</groupId>
      <artifactId>archive-plugin</artifactId>
      <version>1.7.0</version>
      <extensions>true</extensions>
    </plugin>
  </plugins>
</build>

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:

<project 
  xmlns="http://maven.apache.org/POM/4.0.0" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
  http://maven.apache.org/maven-v4_0_0.xsd">
  
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.my-company.test</groupId>
  <artifactId>funkyGame</artifactId>
  <packaging>firebase-gar</packaging>
  <name>Funky Game</name>
  <version>1.0-SNAPSHOT</version>

  <dependencies>
    <dependency>
      <groupId>com.cubeia.firebase</groupId>
      <artifactId>firebase-api</artifactId>
      <version>1.7.0-CE</version>
      <scope>provided</scope>
    </dependency>	
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.14</version>
    </dependency>
  </dependencies>
  
  <build>
    <plugins>
      <plugin>
        <groupId>com.cubeia.tools</groupId>
        <artifactId>archive-plugin</artifactId>
        <version>1.7.0</version>
        <extensions>true</extensions>
      </plugin>
    </plugins>
  </build>
</project>

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:

<plugin>
  <groupId>com.cubeia.tools</groupId>
  <artifactId>firebase-maven-plugin</artifactId>
  <version>1.7.0-CE</version>
  <configuration>
    <deleteOnExit>false</deleteOnExit>
  </configuration>
</plugin>

The run you module with this command:

mvn clean package firebase:run

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.

Personal tools