Maven Build¶
Several GeoTools modules depend on other GeoTools modules, so the first thing you will want to do is perform a full build so that you have a jar from each module installed in your local repository.
Your First Build¶
Start by going to where you have the source code:
cd C:\java\geotools
And check that we actually have the source code:
C:\java\geotools>dir Volume in drive C is INTERNAL Volume Serial Number is 3CA5-71DD Directory of C:\java\geotools\trunk 26/04/2007 11:12 AM <DIR> . 26/04/2007 11:12 AM <DIR> .. 11/01/2007 12:25 AM <DIR> build 01/12/2006 01:27 AM <DIR> demo 04/11/2006 01:04 PM <DIR> doc 16/07/2006 07:56 AM <DIR> licenses 07/04/2007 10:36 AM <DIR> modules 26/04/2007 11:12 AM 52,450 pom.xml 22/10/2006 09:11 AM 3,705 README.txt 26/04/2007 10:08 AM <DIR> target 2 File(s) 56,155 bytes 8 Dir(s) 15,264,776,192 bytes free
Make sure you are connected to the internet
Start your first build:
C:\java\geotools>mvn install
If all is well, Maven should download the required
.jar
files and build GeoTools modules.At the end of this process it will display a list of all the modules which were built and installed correctly.:
[INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 9 months, 3 weeks, 12 hours, 3 minutes, and 43 seconds [INFO] Finished at: Sat Feb 12 16:05:08 EST 2011 [INFO] Final Memory: 41M/87M [INFO] ------------------------------------------------------------------------
The first build takes a while due to the download time for the
.jar
files.
If you have any trouble check the common build failures at the bottom of this page.
Build Failure¶
It is all well and good to recognize a successful build, but how do you recognize a build that has failed?
If your build fails you will get feedback like this:
[INFO] ------------------------------------------------------------------------ [ERROR] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] There are test failures. [INFO] ------------------------------------------------------------------------ [INFO] For more information, run Maven with the -e switch [INFO] ------------------------------------------------------------------------ [INFO] Total time: 7 minutes 56 seconds [INFO] Finished at: Mon Nov 20 12:15:48 PST 2006 [INFO] Final Memory: 23M/42M [INFO] ------------------------------------------------------------------------
You need to scan back through the output and find the “<<< FAILURE!”:
Running org.geotools.data.mif.MIFDataStoreTest Tests run: 9, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 6.703 sec <<< FAILURE!
You can open the test results of the indicated failure in order to see what went wrong. Test results are contained in the target directory.
Expected Build times¶
Depending on your hardware and internet connection:
Building the first time, where maven needs to download everything, may take 20 to 30 minutes.
Future builds check for the most recent
.jar
files from the internet. The checking is based on an md5 checksum and does not take long. Building subsequently may take 10 minutes depending on your hardware and internet connection.After everything is downloaded can build “offline” and avoid the checking of md5 checksums resulting in a faster build of 5-7 minutes.
Finally you can turn off tests (danger!) and build offline to get a build under 2 minutes
Tips to speed up a build:
Do not do a “clean” build if you do not have to
Experiment with the best use of Maven 3 “threading” for your computer
Rebuild a single module after you have modified it
Update your
settings.xml
file to point to a “mirror” in your country - allowing you to download from closer to homeBuild offline (when everything is downloaded to your local repository)
Common Build Problems¶
The following common problems occur during a:
mvn -U clean install
Unable to find org.geotools.maven:javadoc:jar
¶
We have a little of a chicken-and-egg problem here when building a tag for the first time.
To fix you need to build the javadoc jar by hand.
Change to the module directory:
cd build/maven/javadoc
Build the javadoc module:
mvn install
You can now return to the root of the project and restart your build.
Note that this plugin requires your JAVA_HOME to be set to a JDK as it makes use of the tools.jar
(in order to build javadocs).
Unable to Delete Directory on Windows¶
Build systems like Maven (that smash files around for a living) are generally incompatible with Microsoft Indexing Service. From Lim Goh on email
I would also like to point out for future reference that the Windows Indexing Service is not 100% compatible with Maven, and causes some Maven builds to break. Developers who use Windows 7 64-bit (or anything close like Vista or 32-bit) may have unsuccessful build due to “unable to delete directory”. If that happens please try to disable Windows Indexing Service for the entire working copy and try again. Hopefully this will fix the problem.
With this in mind it is also advisable for mac developers to “ignore” build directories from Time Machine (as the files change constantly and Time Machine will burn up your space trying to keep track of it all).