Development

You are encouraged to help contribute code to GeoWebCache. To do so, you will first need to set up the proper development environment.

This is the current prerequisites:

  • Sun/Oracle Java Developer Kit SE, version 1.5
  • Maven 2.x
  • Git

Please make sure you use Java 1.5 to compile to ensure that we do not introduce dependencies only available in 1.6.

You are encouraged to join the GeoWebCache Developers mailing list to discuss your work. It is always a good idea to ask whether anyone else has already solved the same problem.

Setting Up

  1. The Maven build system respects the current setting of JAVA_HOME.

    To define JAVA_HOME be sure to point to the root directory of your JDK.

    Windows:

    set JAVA_HOME=C:\Program Files\Java\jdk1.5.0_21
    

    Linux/OS X:

    export JAVA_HOME=/opt/jdk1.5.0_21
    
  2. You can download maven from http://maven.apache.org/download.html, unpack and include the bin directory in your PATH variable.

    Windows:

    set M2_HOME = C:\java\apache-maven-3.0.5
    set PATH=%PATH%;%M2_HOME%\bin;%JAVA_HOME%\bin
    

    Linux:

    export M2_HOME = ~/java/apache-maven-3.0.5
    export PATH=$PATH:$M2_HOME/bin:$JAVA_HOME/bin
    

    For more detail instructions on maven see the download page.

  3. Test that Maven is installed correctly:

    mvn -version
    
  4. Check that you are using the right version of the javac compiler (as this is determined by PATH, not JAVA_HOME):

    javac -version
    

Build

  1. Check out the code:

    mkdir gwc
    cd gwc
    git clone https://github.com/GeoWebCache/geowebcache.git
    
  2. To build the code, enter the geowebcache directory and run:

    cd geowebcache
    mvn clean install
    
  3. To quickly run a local GeoWebCache for testing:

    cd web
    mvn jetty:run
    
  4. A WAR is built as the last step in mvn clean install above.

    It is located in geowebcache/web/target/geowebcache.war

Setting up Eclipse

  1. Inside the source code directory, run:

    cd geowebcache
    mvn eclipse:eclipse
    

    This generates the .project and .classpath files used to define an Eclipse project.

  2. Create a new workspace in Eclipse

  3. Configure the Maven repository

    • Navigate to Window ‣ Preferences ‣ Java ‣ Build Path ‣ Class Path Variables

    • Add a new variable M2_REPO, and set the path to .m2/repository in your home directory as shown below:

      System PATH
      Windows C:\\Users\You\.m2\repository
      Linux or Mac ~/.m2/repository
  4. Next we will configure Eclipse for working on GeoWebCache files.

    • Navigate to to Java ‣ Code Style ‣ Formatter.
    • Click on Import, choose geowebcache/tools/formatter.xml
  5. There is also a geowebcache/tools/codetemplates.xml to assist with creating new files.

  6. Now we need to import the actual project:

    • Open the appropriate wizard menuselection:File –> Import –> Existing Projects into Workspace
    • Choose your geowebcache folder

    This step depends on the .project and .classpath files generated by mvn eclipse:eclipse above.

  7. To run GeoWebCache use the main menu Run ‣ Debug Configurations and double-click on Java Configurations

    • Set Name: GWC
    • The Project: geowebcache
    • For main class, set Start

    Then press Close, or Debug if you want to try it right away.

Contributing patches

The prefered way of providing patches is to create an issue in GitHub a patch, which you create by running:

git diff > patch.txt

In addition to creating the issue, you are highly encouraged to jump on the GeoWebCache Developers mailing list to introduce the patch.