Grid Dynamics

GigaSpaces Maven Archetype

Blog List Current blog
Log in

 
Victor Samoylov 
As a consulting company focused on grid solutions we often create, modify and build small and big projects based on different grid middleware technologies.
One of most popular technologies we use is GigaSpaces.
In day-to-day work it is often needed to quickly create IDE project with well-defined structure and all required GigaSpaces libs configured. Also it's often a case that different versions of GigaSpaces platform should be used for testing purposes. This can quickly become boring and annoying process. Here I will describe how to automate it using Maven 2 build tool.

There is a good Maven 2 feature which allow to create your own structure of project and use it in the beginning of project. This is a Maven archetype.

The simplest project that works with GigaSpaces require only 3 jars from GigaSpaces XAP product: JSpaces.jar, jsk-lib.jar and jsk-platform.jar. What we usually do to start project? Run the IDE, create new project, attach 3 libraries to project, write the first class with main method. Boring!

To ease our life, we developed a GigaSpaces Maven archetype which you can download here and use right away.

Steps to install gigaspaces-simple-archetype:

  • Download gigaspaces-simple-archetype-6.0.2.zip.
  • Unpack archive.
  • Run "mvn install" command from the folder with pom.xml file.
  • Check that installation succeeded (you will have "BUILD SUCCESSFUL" message on console). Now simple GigaSpaces archetype is in your local Maven repository.


Archetype which you just installed allows to create simple project structure for GigaSpaces XAP 6.0.2 (build 2002).

The only thing you need to create GigaSpaces project is to run the following command (you can also find create-project script inside bin directory in downloaded archive):



mvn archetype:create -DarchetypeGroupId=com.GigaSpaces
-DarchetypeArtifactId=GigaSpaces-simple-archetype -DarchetypeVersion=6.0.2
-DgroupId=com.yourcompanyhere -DartifactId=your-project-name-here


Bingo! You have the GigaSpaces project. You could modify its properties in pom.xml file.

To compile or package the project use "mvn compile" and "mvn package"
commands correspondingly.

I'm sure you will see messages about 3 missing artifacts, it's OK. It's about our required jars from GigaSpaces, so we need to install them in local maven repository or your company dedicated maven repository.

You should download GigaSpaces XAP 6.0.2 (build 2002) distributive and install its artifacts into local maven repository. Following commands will help you:



mvn install:install-file -DgroupId=com.GigaSpaces -DartifactId=jspaces -Dversion=6.0.2-2002 -Dpackaging=jar -Dfile=JSpaces.jar

mvn install:install-file -DgroupId=com.GigaSpaces.jini -DartifactId=jsk-lib -Dversion=6.0.2-2002 -Dpackaging=jar -Dfile=jsk-lib.jar

mvn install:install-file -DgroupId=com.GigaSpaces.jini -DartifactId=jsk-platform -Dversion=6.0.2-2002 -Dpackaging=jar -Dfile=jsk-platform.jar


After that project is ready-to-use. Popular IDEs (like Eclipse, NetBeans, IDEA) natively support Maven 2 today. You could also automatically generate project for your IDE:

Eclipse

mvn eclipse:clean eclipse:eclipse

IDEA

mvn idea:clean idea:idea

or even create Ant build script

mvn ant:clean ant:ant



Enjoy power of Maven archetypes!


References and used products:

Maven 2 (version 2.0.7)
http://maven.apache.org/

Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.


GigaSpaces XAP 6.0.2 (build 2002)
http://www.gigaspaces.com/

GigaSpaces eXtreme Application Platform (XAP) redefines scalability with a holistic Space-based Architecture (SBA) approach that provides a single platform for managing the data, messaging, and business logic associated with a business transaction.

Category:  GigaSpaces


© 2008 Grid Dynamics Consulting Services, Inc. All rights reserved.