Back to DevDoc

Maven

The SimExplorer project uses maven as source project management and is IDE-agnostic, so it is designed to be use in any IDE and use exclusively maven (with some ant tasks) for build process. Currently developpers are using Eclipse and Netbeans.

Maven references:

A website is generated automatically by maven on our hudson server.

Usefull Maven plugin / goals

You should run these maven goals within the directory that contains the pom.xml file.

  • Clean the project (mainly remove the target sub-directory)
    mvn clean
    
  • Package the project
    mvn package
    
  • Install the built artifacts in your local repository, so they can be used by other maven projects
    mvn install
    
  • Deploy the built artifacts in the common repository (you must have a login on our server)
    mvn deploy
    

If you want to deploy additional libraries:

  • quickly in your local repository:
    mvn install:install-file -DgroupId=org.simexplorer -DartifactId=org.company.project -Dversion=x.x.x -Dpackaging=jar -Dfile=yourlib-x.x.x.jar
    
    • org.simexplorer as groupId is a good idea, because it will be easier to know who has packaged this library
    • Replace {{{x.x.x}} by the version of your library
  • with a full pom file, following this guide is a good idea, especially if you intend to publish your lib on our repository.
    mvn install:install-file -DpomFile=your-pom.xml -Dfile=yourlib-x.x.x.jar
    
  • to deploy your library on an central repository (you must have a login on our server):
    mvn deploy:deploy-file -DpomFile=your-pom.xml -Dfile=yourlib-x.x.x.jar -Durl=http://trac.clermont.cemagref.fr/nexus/content/repositories/thirdparty/ -DrepositoryId=trac.clermont.cemagref.fr.nexus
    
  • to manage dependencies:
    mvn dependency:analyze # analyse the use of declared deps
    mvn dependency:tree    # print the tree of deps
    mvn dependency:purge-local-repository # remove retrieved deps in your local repo
    

SimExplorer Maven repository

SimExplorer delivers a public maven repository. This repository contains SimExplorer releases and snapshots, and serves as a proxy all external repositories needed for building SimExplorer.

If you want to use this repository as a proxy, you can add it in your maven settings. For example, your ~/.m2/settings.xml file could look like:

<?xml version="1.0" encoding="UTF-8"?>
<settings>
    <mirrors>
        <mirror>
            <id>simexplorer</id>
            <name>SimExplorer repository</name>
            <url>http://maven.simexplorer.org/repo/</url>
            <mirrorOf>central, SE-springsource-release, SE-springsource-external, SE-IN2P3, SEIS-codelutin, SE-nuiton, SE-restlet</mirrorOf>
        </mirror>
    </mirrors>
</settings>

Add a third-party library (>=0.3)

Since the 0.3 version, the third-party libraries management has been improved. As SimExplorer is base on Equinox OSGi framework, libraries should be prodived as OSGi bundles. There is three ways for adding a new library:

  1. your library is available as pre-built bundle in a maven repository (for example in springsource repository)
  2. your library is available as jar dependency in a maven repository (look at there)
  3. your library isn't available in any maven repository, you have two solutions:

In any case, use the dependencyManagement section in the main pom.xml to precise at the higher the library used, and simplify the libraries versions management.

Add a library available as OSGi bundle

  • Add the dependancy in the dependencyManagement section of the main pom.xml
  • Add the dependancy (without version attribute) in the libraries/plugins

Add a library available as jar

  • Choose what will be the symbolic name of the bundle, commonly the main package of the lib (for example org.society.libname)
  • Add a property in the main pom.xml (at the end) with a name following the scheme "lib.yoursymbolicname.version" to set the version of the dependancy used, for example :
            <lib.org.society.libname.version>0.5.7</lib.org.society.libname.version>
    
  • Add the dependancy in the dependencyManagement section of the main pom.xml, using the previously defined property to set the version, for example :
                <dependency>
                    <groupId>org.society</groupId>
                    <artifactId>libname</artifactId>
                    <version>${lib.org.society.libname.version}</version>
                </dependency>
    
  • in the directory simexplorer/libraries/plugins, make a copy of the directory bnd-sample to a directory with your symbolic name as name, and open the pom.xml file in this new directory and adjust the settings tagged with TODO. Make a SVN safe copy, or delete the subdirectory .svn copied in the new directory. At the end, the file should look like:
        …
        <artifactId>org.society.libname</artifactId>
        <version>${lib.org.society.libname.version}</version>
        <dependencies>
            <dependency>
                <groupId>org.society</groupId>
                <artifactId>libname</artifactId>
                <scope>provided</scope>
            </dependency>
        </dependencies>
    
  • by default, all packages are exported, if you want to limitate them, do something like that:
        <properties>
            <export.packages>
                org.society.libname
                org.society.libname.objects
            </export.packages>
        </properties>
    
  • Endly add the created module to the parent one libraries, by adding it in the modules section of simexplorer/libraries/pom.xml, for example :
         <artifactId>libraries</artifactId>
        <modules>
            <module>org.society.libname</module>
            <module>plugins</module>
        </modules>
    
    

See also this article

Build the Equinox product (<=0.2)

To build the equinox product, you have to build the simexplorer-runtime module. The following bash method definition could then be used to easily build a sub-module

buildModule() { cd $1/; mvn -o -Dmaven.test.skip=true package; cd ..; }

For example, the following command builds in quick mode the simexplorer-core, simexplorer-methods and the simexplorer-runtime modules (it could be usefull if you're working on the IDE), without running the tests, and in the offline mode.

buildModule simexplorer-core && buildModule simexplorer-methods && buildModule simexplorer-runtime

And if you want to rebuild the NetBeans after:

buildModule simexplorer-core && buildModule simexplorer-methods && buildModule simexplorer-runtime && cd ../simexplorer-ide-suite/lwm-simexplorer-all/ && ant clean release && cd ../../simexplorer

Notes about NetBeans maven archetype

Attempt to create a NetBeans platform based application using maven (Netbeans 6.5, maven plugin 4.0.5):

  • Create a new project
  • Choose "maven project"
  • Choose the archetype "Maven Netbeans Platform Application Archetype" (org.codehaus.mojo.archetypes:netbeans-platform-app-archetype:1.1" - announce)
  • You have 4 projects created:
    • A pom project that is the module suite ?
    • A nbm-application sub-module dedicated to ?
    • A nbm sub-module dedicated for branding your application
    • A nbm sub-module example for your platform dev
  • Seems to useless (try without): In the pom.xml of the pom project, set the properties netbeansInstallation in the configuration of nbm-maven-plugin
  • Build the pom project
  • Select the nbm-application module, and run the goal nbm:run-platform
  • For debugging, run the goal nbm:run-platform with property netbeans.run.params=-J-Xdebug -J-Xnoagent -J-Xrunjdwp:transport=dt_socket,suspend=n,server=y,address=8888 (see nbm plugin doc), and then attach the debugger to the socket.
  • For profiling, run the goal nbm:run-platform with property netbeans.run.params=-J-agentpath:/opt/netbeans-6.5.1/profiler3/lib/deployed/jdk15/linux/libprofilerinterface.so=/opt/netbeans-6.5.1/profiler3/lib,5140 and then attach the profiler (don't forget to corretly configure the attach point).

logo cemagref

logo iscpif

logo lifegrid

logo region auvergne

logo patres project