Simplifying gvSIG desktop eclipse launcher thanks to the jar file classpath support

In the gvSIG 2.0 development branch we are trying to make the compilation and building process as easy as we can. We try (with more or less success) to lower as much as possible the complexity needed to build gvSIG or any of its plugins, even more for new developers who want to start hacking, solving bugs or adding new funcionalities.

One of those things we added to make developer’s life easier is the creation of gvSIG desktop launchers, so if you create a new plugin and workspace or you just try to build the gvSIG core projects, you will have it already available in your eclipse “Run configurations” menu.

Initially, we created the launchers by adding in the classpath tab all the andami jar files and its dependencies:

Initial gvSIG launcher classpath configuration

Initial gvSIG launcher classpath configuration

It worked very well until we had to change or upgrade any of the Andami dependencies. Then all previously prepared launchers where broken and had to be updated by hand.

Looking for a solution, we found that a jar file is able to define the classpath of its dependencies, thanks to the Class-Path: entry in the MANIFEST.MF file. So if we were able to create that entry while generating the andami jar file, we could simplify the gvSIG launchers, making them independent of andami dependency changes. Something like this:

Simplifyied launcher classpath

Simplifyied launcher classpath

Luckily one of the changes performed in the gvSIG desktop 2.0 branch has been to change the build process from ant to maven, and the maven-jar-plugin has an option to fill the Class-path MANIFEST.MF entry automatically from the project dependencies.

So we only needed to add the following to the pom.xml file of the _fwAndami project:


And that’s all. Once you perform a mvn install on the andami project and the andami jar file is generated, if you open it and look into the META-INF/MANIFEST.MF file, the contents will look something like:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Build-Jdk: 1.6.0_24
Main-Class: org.gvsig.andami.Launcher
Built-By: gvSIG Team
Class-Path: slf4j-api-1.5.5.jar slf4j-log4j12-1.5.5.jar log4j-1.2.14.j
 ar kxml2-2.2.2.jar xmlpull-1.1
 .3.1.jar org.gvsig.i18n
 -2.0.1-SNAPSHOT.jar org.
 APSHOT.jar org.gv
 sig.utils-2.0-SNAPSHOT.jar castor- org.gvsig.ui-2.0.1-SNAP
 SHOT.jar jcommon-1.0.12.jar jfreechart-1.0.7.jar jwizardcomponent-1.2
 .2.jar org.gvsig.installer.lib.api-1.0.1-SNAPSHOT.jar org.gvsig.insta
 ller.lib.impl-1.0.1-SNAPSHOT.jar org.gvsig.installer.lib.spi-1.0.1-SN
 APSHOT.jar org.gvsig.installer.prov.plugin-1.0.1-SNAPSHOT.jar ant-1.8
 .1.jar ant-launcher-1.8.1.jar org.gvsig.installer.swing.api-1.0.1-SNA
 PSHOT.jar org.gvsig.installer.swing.impl-1.0.1-SNAPSHOT.jar batik-gui
 -util-1.7.jar batik-util-1.7.jar batik-xml-1.7.jar javahelp-2.0.05.ja
 r looks-2.1.4.jar xercesImpl-2.5.0.jar

This also has the benefit of being able to launch gvSIG from command line very easily. Just go into your gvSIG folder and run the following command (albeit defining some environment variables would be needed also for the native libraries to work as expected):

java -jar lib/org.gvsig.andami-2-SNAPSHOT.jar gvSIG gvSIG/extensiones

About cordin

I'm the CTO of the DiSiD Technologies ( company, and also one of the gvSIG project ( software architects.
This entry was posted in development, english, gvSIG Desktop, gvSIG development and tagged , , , . Bookmark the permalink.

1 Response to Simplifying gvSIG desktop eclipse launcher thanks to the jar file classpath support

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s