Our policy is waiting for the majority of our users before migrating to a new version of the Java language. In general we are held up by the slow migration of Java Enterprise Edition environments such as websphere.
GeoTools 8 uses Java 6.
Complete build instructions are provided in the user guide:
GeoTools makes use of the maven build system (in part to help us reused code from a number of other java projects).
To build all the modules:
mvn install -Dall
To load the modules into the eclipse IDE.
Use Windows ‣ Preferences to open the Preference Dialog. Using the tree on the left navigate to the Java > Build path > Classpath Variables preference Page.
Add an M2_REPO classpath variable pointing to your local repository where maven downloads jars.
PLATFORM
LOCAL REPOSITORY
Windows XP:
C:\Documents and Settings\Jody\.m2\repository
Windows:
C:\Users\Jody.m2\repository
Linux and Mac:
~/.m2/repository
Generate the .project and .classpath files needed for eclipse:
mvn eclipse:eclipse -Dall
Maven 3 is not faster out of the box with the default settings.
Gowever what is new is that you can ask it to use more than one core:
mvn install -Dall -T 2C
The above asks the build to go in “threaded” mode; using two threads for each core.
This is the fastest build on my machine:
mvn install -DskipTests -o -T 2C
The above options:
I use this configuration to quickly push all local changes into my local maven repository so I can test in a downstream application such as uDig or GeoServer.
If you’re familiar with Maven you might have used the assembly plugin to create self-contained, executable jars. The bad news is that this generally won’t work with GeoTools. The problem is that GeoTools modules often define one or more files in its META-INF/services directory with the same names as files defined in other modules. The assembly plugin just copies files with the same name over the top of each other rather than merging their contents.
The good news is that the Maven shade plugin can be used instead and it will correctly merge the META-INF/services files from each of the GeoTools modules used by your application.
The POM below will create an executable jar for the GeoTools Quickstart module which includes all of the required GeoTools modules and their dependencies.
<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>
<groupId>org.geotools.demo</groupId>
<artifactId>quickstart</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<name>GeoTools Quickstart example</name>
<url>http://geotools.org</url>
<properties>
<geotools.version>2.6.2</geotools.version>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
<target>1.5</target>
<source>1.5</source>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.3.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<!-- This bit sets the main class for the executable jar as you otherwise -->
<!-- would with the assembly plugin -->
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>org.geotools.demo.Quickstart</Main-Class>
</manifestEntries>
</transformer>
<!-- This bit merges the various GeoTools META-INF/services files -->
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-shapefile</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-epsg-hsql</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-swing</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.5</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>