Added by James Macgill, last edited by Adrian Custer on Jul 12, 2006  (view change)

Labels:

Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.

Using the SNAPSHOT releases.

This is a collection of notes on using the new snapshot release system. It was almost completly written when the browser (firefox!) died an killed it, so here comes a much shorter version...

Introduction

This guide assumes that you know what Maven is, how it works (mostly) and that you want to build your own project using maven.

GeoTools is a very active project with up to 30 active developers working on code, so changes are almost constant. We try to put out milestone releases about once a month, but we don't always manage it, and that is still a long time to wait for a fix or improvment. To get round this problem we have started producing SNAPSHOT builds at the start of each day, this document explains how you can use maven to build your project against the latest snapshot release automaticaly.

The snapshot repository

You can find the snapshot jars online at http://dist.geotools.org/ (Maven 1) or http://maven.geotools.org/gt2/org/geotools/ (Maven 2). If you are familier with Maven then this site should make sense to you, if not take a look inside gt2/jars (Maven 1) and you will find the snapshot jars as well as dated release jars. (In the near future we plan to include stable releases in this repository too).

Adding the repository to your projects config

Maven 1

Edit (or add) the following line in your project.properties file:

maven.repo.remote = http://dist.geotools.org,      \
                    http://www.ibiblio.org/maven/, \
                    http://lists.refractions.net/geotools/

The first repository in that list is the snapshot home, the others contain 3rd party jars used by the GeoTools library. You probably already have the main maven repository in your list, but make sure.

Maven 2

Edit (or add) the following lines in your pom.xml file:

<repositories>
  <repository>
    <id>geotools</id>
    <name>Geotools repository</name>
    <url>http://maven.geotools.fr/repository</url>
  </repository>
  <repository>
    <id>ibiblio</id>
    <name>Ibiblio - the public's library and digital archive</name>
    <url>http://www.ibiblio.org/maven2</url>
  </repository>
</repositories>

The first repository is the snapshot home. The second one contains 3rd party jars used by the GeoTools library. If ibiblio is slow, consider using a mirror instead (e.g. http://public.planetmirror.com/pub/maven2).

Add the dependencies

The next step is to edit your project.xml (Maven 1) or pom.xml (Maven 2) file so that it includes the GeoTools jars that you want to use, as the the 3rd party jars that they need. The follwoing is a fairly complete example that includes the main GeoTools jars as well as a number of common Data Store implementations. Note that the Maven 2 example is simplier than the Maven 1 example because transitive dependencies don't need to be specified with Maven 2.

Maven 1
<dependencies>
  <dependency>
    <artifactId>main</artifactId>
    <groupId>gt2</groupId>
    <version>SNAPSHOT</version>
  </dependency>
  <dependency>
    <artifactId>migrate</artifactId>
    <groupId>gt2</groupId>
    <version>SNAPSHOT</version>
  </dependency>
  <dependency>
    <artifactId>legacy</artifactId>
    <groupId>gt2</groupId>
    <version>SNAPSHOT</version>
  </dependency>
  <dependency>
    <artifactId>vecmath</artifactId>
    <groupId>vecmath</groupId>
    <version>1.3</version>
  </dependency>
  <dependency>
    <artifactId>opengis-legacy</artifactId>
    <groupId>opengis</groupId>
    <version>0.1</version>
  </dependency>
  <dependency>
    <artifactId>shapefile</artifactId>
    <groupId>gt2</groupId>
    <version>SNAPSHOT</version>
  </dependency>
  <dependency>
    <artifactId>geoapi</artifactId>
    <groupId>geoapi</groupId>
    <version>2.0</version>
  </dependency>
  <dependency>
    <artifactId>units</artifactId>
    <groupId>units</groupId>
    <version>0.01</version>
  </dependency>
  <dependency>
    <artifactId>postgis-driver</artifactId>
    <groupId>postgis-driver</groupId>
    <version>1.0</version>
  </dependency>
  <dependency>
    <artifactId>postgresql</artifactId>
    <groupId>postgresql</groupId>
    <version>74.213</version>
  </dependency>
  <dependency>
    <artifactId>postgis</artifactId>
    <groupId>gt2</groupId>
    <version>SNAPSHOT</version>
  </dependency>
  <dependency>
    <artifactId>wfs</artifactId>
    <groupId>gt2</groupId>
    <version>SNAPSHOT</version>
  </dependency>
  <dependency>
    <artifactId>referencing</artifactId>
    <groupId>gt2</groupId>
    <version>SNAPSHOT</version>
  </dependency>
  <dependency>
    <artifactId>coverage</artifactId>
    <groupId>gt2</groupId>
    <version>SNAPSHOT</version>
  </dependency>
  <dependency>
    <artifactId>wms</artifactId>
    <groupId>gt2</groupId>
    <version>SNAPSHOT</version>
  </dependency>
  <dependency>
    <groupId>JTS</groupId>
    <artifactId>JTS</artifactId>
    <version>1.6</version>
    <url>http://www.vividsolutions.com/JTS/jts_frame.htm</url>
  </dependency>
</dependencies>
Maven 2
<dependencies>
  <dependency>
    <groupId>org.geotools</groupId>
    <artifactId>gt2-main</artifactId>
    <version>2.2-RC0</version>
  </dependency>
  <dependency>
    <groupId>org.geotools</groupId>
    <artifactId>gt2-shapefile</artifactId>
    <version>2.2-RC0</version>
  </dependency>
  <dependency>
    <groupId>org.geotools</groupId>
    <artifactId>gt2-postgis</artifactId>
    <version>2.2-RC0</version>
  </dependency>
  <dependency>
    <groupId>org.geotools</groupId>
    <artifactId>gt2-wfs</artifactId>
    <version>2.2-RC0</version>
  </dependency>
  <dependency>
    <groupId>org.geotools</groupId>
    <artifactId>gt2-wms</artifactId>
    <version>2.2-RC0</version>
  </dependency>
</dependencies>

Using the 'offline' build mode (Maven 1 only)

The one drawback to using the SNAPSHOT releases as opposed to a stable release is that Maven 1 will attempt to download the jars everytime you do anything. Even if their are no changes detected the process of checking can take time, especialy if you have a long list of remote repositories. A handy workaround for this is Mavens 'offline' mode. Simply use the '-o' switch and maven will stop checking for snapshot changes.

Mavenide for netbeans users

Maven ide for netbeans (and probably idea and eclipse) provides an easy way to switch offline mode on and off. Go to Tools->Options->Maven Settings.

The problem doesn't apply to Maven 2, since Maven 2 checks for snapshot only at some intervale. By default, Maven 2 checks for updates once a day. But this interval may be configured with a <updatePolicy> element in the pom.xml file.

Complete pom.xml example (Maven 2)

<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- ===========================================================================
         Maven 2 project configuration file
         http://maven.apache.org/
     =========================================================================== -->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>


  <!-- ==================================================== -->
  <!--     Project description                              -->
  <!-- ==================================================== -->
  <groupId>com.mycompagny</groupId>
  <artifactId>myproject</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>My application on top of Geotools library</name>
  <url>http://www.mycompagny.com/myproject/</url>
  <description>
    There is a long description of my project.
  </description>

  <organization>
    <name>My compagny</name>
    <url>http://www.mycompagny.com/</url>
  </organization>
  <inceptionYear>2005</inceptionYear>

  <scm>
    <connection>scm:svn:http://svn.mycompagny.com/myproject/</connection>
    <url>http://svn.mycompagny.com/myproject/</url>
  </scm>


  <!-- ==================================================== -->
  <!--     Developers and contributors                      -->
  <!-- ==================================================== -->
  <developers>
    <developer>
      <id>mylogging</id>
      <name>MyName</name>
      <email>myname@mycompagny.com</email>
      <organization>My compagny</organization>
      <roles>
        <role>Java Developer</role>
      </roles>
    </developer>
  </developers>


  <!-- ==================================================== -->
  <!--     Dependencies                                     -->
  <!-- ==================================================== -->
  <dependencies>
    <dependency>
      <groupId>org.opengis</groupId>
      <artifactId>geoapi</artifactId>
      <version>2.0</version>
    </dependency>
    <dependency>
      <groupId>org.geotools</groupId>
      <artifactId>gt2-referencing</artifactId>
      <version>2.2-RC0</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <repositories>
    <repository>
      <id>geotools</id>
      <name>Geotools repository</name>
      <url>http://maven.geotools.fr/repository</url>
    </repository>
    <repository>
      <id>ibiblio</id>
      <name>Ibiblio - the public's library and digital archive</name>
      <url>http://www.ibiblio.org/maven2</url>
    </repository>
  </repositories>


  <!-- ==================================================== -->
  <!--     Build configuration                              -->
  <!-- ==================================================== -->
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
              <mainClass>com.mycompagny.myproject.MyMainClass</mainClass>
              <addClasspath>true</addClasspath>
            </manifest>
          </archive>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>