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:
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:
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:
<build> <plugins> ... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <mainClass>org.gvsig.andami.Launcher</mainClass> </manifest> </archive> </configuration> </plugin> </plugins> </build>
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 org.gvsig.tools.lib-3.0.0-SNAPSHOT.jar kxml2-2.2.2.jar xmlpull-1.1 .3.1.jar org.gvsig.maven.base.tools-1.0.8-SNAPSHOT.jar org.gvsig.i18n -2.0.1-SNAPSHOT.jar org.gvsig.tools.swing.api-3.0.0-SNAPSHOT.jar org. gvsig.tools.swing.impl-3.0.0-SNAPSHOT.jar org.gvsig.tools.swing.spi-3 .0.0-SNAPSHOT.jar org.gvsig.tools.swing.serv.field-3.0.0-SNAPSHOT.jar flib-jcalendar-unknown.jar org.gvsig.tools.swing.serv.jform-3.0.0-SN APSHOT.jar org.gvsig.tools.swing.serv.jlist-3.0.0-SNAPSHOT.jar org.gv sig.utils-2.0-SNAPSHOT.jar castor-0.9.5.3.jar 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