GraphStream & Maven
What you have to know about Maven
Maven is a tool to help you managing a project. It allows
to compile, test and package projects. It also provides
a way to manage dependencies by automaticaly looking for
your project dependencies in a remote repository and
installing them on your local repository (“
on unix systems).
You can find more informations about Maven at Wikipedia.
Maven defines goals that are tasks to be performed and that are included in a build lifecycle. Initially, this lifecycle is:
Interesting goals here are compile, test, package and install. compile is trivial to understand : it compiles classes of your project. test compiles test-classes of your project and runs these test (using junit). package creates packaged distribution of your project and install installs your project in your local maven repository.
Description about “how to build your project” are contained
in a Project Object Model (POM) using the XML format. Have
a look on
gs-core/pom.xml for an example. Dependencies of your project are set in this POM.
Each project, called artifact, is identified by three informations :
- a group id, it allows to group several artifacts together. For example
org.graphstreamis common to every GraphStream artifact;
- an artifact id, for example
gs-core, this id has to be unique according to the group;
- and a version,
These information are defined in the POM using the following tags:
<project> ... <artifactId>gs-core</artifactId> <groupId>org.graphstream</groupId> <version>2.0</version> ... </project>
Using snapshot versions
A snapshot is a version of Graphstream that has not been released. The difference between a real version and a snapshot is that snapshot might still get updates. Snapshot versions are useful during development process. To use them you can add the branch name followed by -SNAPSHOT in the version.
<dependency> <groupId>com.github.graphstream</groupId> <artifactId>gs-core</artifactId> <version>dev-SNAPSHOT</version> </dependency>
Building GraphStream using Maven
To install any
gs-xxx module, just follow the process above,
git clone git://github.com/graphstream/gs-xxx.git cd gs-xxx # to pull changes if project has been already cloned git pull mvn install
In the case where only the build of the package is needed, just run the:
in the module directory. This will produce a
gs-xxx/target that you can use directly. Be careful, this jar
does not include dependencies, for example, building the jar of
gs-core does not include classes of
From version 2, an additional jar is provided with dependencies :
Using non-maven jar in a Maven project
If you want to use a jar which is not in Maven repository, you can install it directly, providing meta-informations. Just use the following command (replacing
$Version with the correct values) :
mvn install:install-file -Dfile=MyJar.jar -DgroupId=$GroupId -DartifactId=$ArtifactId -Dversion=$Version -Dpackaging=jar
Next, you will be able to use this jar as a Maven dependency in your project.