This document is about configuring Gerrit Code Review into an Eclipse workspace for development.
Java 11 or later SDK is required. Otherwise, java 8 can still be used for now as described below.
In your Eclipse installation’s
add the following line in the
Without this setting, annotation processing does not work reliably and the build is likely to fail with errors like:
Could not write generated class ... javax.annotation.processing.FilerException: Source file already created
AutoAnnotation_Commands_named cannot be resolved to a type
First, generate the Eclipse project by running the
If running Eclipse on Java 8, add the extra parameter
for generating a compatible project.
Then, in Eclipse, choose 'Import existing project' and select the
from the current working directory.
gerrit project, right-click on the
eclipse-out folder, select
'Properties', and then under 'Attributes' check 'Derived'.
Note that if you make any changes in the project configuration
that get saved to the
.project file, for example adding Resource
Filters on a folder, they will be overwritten the next time you run
Eclipse project on MacOS
By default, bazel uses
/private/var/tmp as the
outputRoot on MacOS.
This means that the eclipse project will reference libraries stored under that directory.
However, MacOS runs periodic cleanup task which deletes the content under
which wasn’t accessed or modified for some days, by default 3 days. This can lead to a broken
Eclipse project as referenced libraries get deleted.
There are two possibilities to mitigate this issue.
Change the location of the bazel output directory
On Linux, the output directory defaults to
$HOME/.cache/bazel and the same can be configured
on Mac too. Edit, or create, the
$HOME/.bazelrc file and add the following line:
Increase the treshold for the cleanup of temporary files
The default treshold for the cleanup can be overriden by creating a configuration file under
/etc/periodic.conf and setting a larger value for the
# This file overrides the settings from /etc/defaults/periodic.conf daily_clean_tmps_days="45" # If not accessed for
For more details about the proposed workaround see this post
Eclipse project with custom plugins
To add custom plugins to the eclipse project add them to
the same way you would when
bundling in release.war
Java 11 is supported as a default, but some adjustments must be done for other JDKs:
Add JRE, e.g.: directory: /usr/lib64/jvm/java-9-openjdk, name: java-9-openjdk-9
Change execution environment for gerrit project to: JavaSE-9 (java-9-openjdk-9)
Check that compiler compliance level in gerrit project is set to: 9
Moreover, the actual java 11 language features are not supported yet.
Code Formatter Settings
To format source code, Gerrit uses the
tool (version 1.7), which automatically formats code to follow the
style guide. See Code Style for the
instruction how to set up command line tool that uses this formatter.
The Eclipse plugin is provided that allows to format with the same
formatter from within the Eclipse IDE. See
for details how to install it. It’s important to use the same plugin version
The Gerrit web app UI is served by
server.go process. To launch it,
run this command:
$ bazel run polygerrit-ui:devserver
Running the Daemon
Duplicate the existing launch configuration:
In Eclipse select Run → Debug Configurations …
Java Application →
Right click, Duplicate
Modify the name to be unique.
Switch to Arguments tab.
-dprogram argument flag to match the path used during 'init'. The template launch configuration resolves to
../gerrit_testsitesince that is what the documentation recommends.
Switch to Common tab.
Change Save as to be Local file.
Close the Debug Configurations dialog and save the changes when prompted.
Part of Gerrit Code Review