IntelliJ QuickStart

Check out source code

Check out the source code from the git repository.:

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

To list the available branches.:

% git branch
   2.21.x
   2.22.x
 * main

Choose main for the latest development.:

% git checkout main

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

% git checkout 2.22.x

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

Import modules into IntelliJ

  1. Run the IntelliJ IDE

  2. From the initial panel select Open.

    ../_images/intellij_open.png
  3. Navigate to the geoserver/src/pom.xml directory and click OK.

    ../_images/intellij_import.png
  4. When asked click on Open as a Project.

    ../_images/intellij_project.png
  5. Optionally, depending on which platform, IntelliJ may ask to Trust the Project.

    ../_images/intellij_project_trust.png
  6. Wait for IntelliJ to Sync the dependencies, it’s possible to follow the process from the Build tab panel on the bottom.

    ../_images/intellij_sync.png

Finalize the GeoServer Project configuration

  1. Click File > Project Structure.

    ../_images/intellij_project_structure.png
  2. Update the Name and select the correct SDK accordingly to the GeoServer version.

    ../_images/intellij_project_sdk.png
  3. Click File > Settings.

    ../_images/intellij_project_settings.png
  4. From Build, Execution, Deployment > Compiler > Annotation Processors, enable the Annotation processing.

    ../_images/intellij_project_settings_annotation_processing.png
  5. Click Build > Rebuild Project.

    ../_images/intellij_project_rebuild.png

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 Modify Run Configuration...

    ../_images/intellij_run.png
  4. It is important to correctly set the Working directory to src/web/app. While having the Edit Configurations dialog open, fine tune the launch environment (including setting a GEOSERVER_DATA_DIR or the jetty.port). When settings are satisfactory, click OK.

    ../_images/intellij_run_config.png
  5. It’s possible now to run GeoServer by selecting Run -> Run 'Start'

    ../_images/intellij_run_start.png

Troubleshooting

  1. 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.

  2. In the case of compiler errors like java.lang.NoSuchMethodError, it might be due to Error Prone. 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. 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 slow down the build.

  3. 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.

  4. 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_project_settings_annotation_processing.png
  5. If IntelliJ complains with an error message like Command line is too long., click on Shorten the command line and run.

    ../_images/intellij_run_start_error.png

Note

If there’s a server running on localhost:8080 please check the Eclipse Guide for instructions on changing to a different port.

Run GeoServer with Extensions

The above instructions assume running GeoServer without any extensions enabled. In cases where certain extensions are needed, 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 tool and select the profile(s) to enable.

../_images/intellij_run_profile.png

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

In order to sync the GeoServer execution with the new modules, from the Maven Projects tool click the Reload All Maven Project button (1), then Build the Project (2) and, once finished, Run 'Start' (3).

../_images/intellij_run_profile_sync.png

Access GeoServer front page