IntelliJ QuickStart

Check out source code

Check out the source code from the git repository.:

git clone git://github.com/geoserver/geoserver.git geoserver

To list the available branches.:

% git branch
   2.15.x
   2.16.x
 * main

Choose main for the latest development.:

% git checkout main

Or chose a stable branch for versions less likely to change often:

% git checkout 2.16.x

In this example we will pretend that your source code is in a directory called geoserver, but a more descriptive name is recommended.

Import modules into IntelliJ

  1. Run the IntelliJ IDE

  2. Select File -> New -> Project from Existing Sources....

  3. Navigate to the geoserver/src/pom.xml directory and click Open.

    ../_images/intellij_import.png
  4. Click Next, leaving all profiles unchecked.

    ../_images/intellij_import_profile.png
  5. Click Next, leaving the geoserver project checked.

    ../_images/intellij_import_project.png
  6. Click Next, selecting the Java 8 JDK of your choice.

    ../_images/intellij_import_jdk.png
  7. Click Finish

    ../_images/intellij_import_finish.png

Before Running GeoServer

GeoServer relies on other libraries that are maintained in parallel under the same project umbrella. These are GeoTools and GeoWebCache. So, for easier installation and setup of the GeoServer development environment, you may want to apply the following:

  1. Download the code of both and execute mvn clean install into them.

    GeoTools GeoWebCache

  2. Afterwards do the same in the GeoServer src folder

Run GeoServer from IntelliJ

  1. From the Project browser select the web-app module

  2. Navigate to the org.geoserver.web package

  3. Right-click the Start class and click to Run 'Start.main()'

    ../_images/intellij_run.png
  4. The first time you do this, GeoServer will fail to start. Navigate to the Run menu, and click Edit Configurations....

  5. Select the Start configuration, and append web/app to the Working Directory.

    ../_images/intellij_run_config.png
  6. While you have the Edit Configurations dialog open, you can fine tune your launch environment (including setting a GEOSERVER_DATA_DIR). When you are happy with your settings, click OK.

  7. If there are errors such as “cannot find symbol class ASTAxisId”, some generated code is not being included in the build. Using wcs1_1 as the working directory, run a mvn clean install.

  8. If you get a compiler error like java.lang.NoSuchMethodError, it is most likely due to Error Prone tool which doesn’t support Java 8. This tool is switched off by default, but sometimes it turns on after import to IntelliJ. There are two options to fix it:
    1. Go to Maven tool window and uncheck the errorprone profile, then click Reimport All Maven Projects:

      ../_images/intellij_maven_errorprone.png
    2. If you want to use errorprone, notably to perform the QA checks, install the Error Prone Compiler plugin, restart the IDE and set Javac with error-prone as a default compiler for the project. Please note that this will slower the build.

  9. If there are errors such as “cannot find symbol AbstractUserGroupServiceTest”, rebuild the security-tests project in the security module. Right-click on the security-tests project and click Rebuild.

  10. In the last versions of IntelliJ Annotations processors are enabled. If there are errors because of this uncheck this option from compiler settings.

    ../_images/intellij_disable_annotation_processors.jpg
  11. You can now re-run GeoServer. Select Run -> Run 'Start'

Note

If you already have a server running on localhost:8080 see the Eclipse Guide for instructions on changing to a different port.

Run GeoServer with Extensions

The above instructions assume you want to run GeoServer without any extensions enabled. In cases where you do need certain extensions, the web-app module declares a number of profiles that will enable specific extensions when running Start. To enable an extension, open the Maven Projects window (View -> Tool Windows -> Maven Projects) and select the profile(s) you want to enable.

../_images/intellij_run_profile.png

The full list of supported profiles can be found in src/web/app/pom.xml.

Access GeoServer front page

Run GeoServer from IntelliJ on Windows

  1. Add bash to your Windows environment path and restart IntelliJ.