First, generate the Eclipse project by running the tools/eclipse/project.py script.
Then, in Eclipse, choose 'Import existing project' and select the gerrit project
from the current working directory.

Expand the 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
tools/eclipse/project.py.

Eclipse project with custom plugins

To add custom plugins to the eclipse project add them to tools/bzl/plugins.bzl
the same way you would when
bundling in release.war
and run tools/eclipse/project.py.

[[Newer Java versions]]

Java 9 and later are supported, but some adjustments must be done, because
Java 8 is still the default:

Code Formatter Settings

To format source code, Gerrit uses the
google-java-format
tool (version 1.3), 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
Eclipse plugin
for details how to install it. It’s important to use the same plugin version
as the google-java-format script.

Site Initialization

Build once on the command line with
Bazel and then follow
Site Initialization in the
Developer Setup guide to configure a local site for testing.

Testing

Running the Daemon

Duplicate the existing launch configuration:

In Eclipse select Run → Debug Configurations …​

Java Application → gerrit_daemon

Right click, Duplicate

Modify the name to be unique.

Switch to Arguments tab.

Edit the -d program argument flag to match the path used during
'init'. The template launch configuration resolves to ../gerrit_testsite
since 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.

Select the gerrit_ui module to compile (the Compile button can also be used
as a bookmarklet).

In the developer tools source tab, open a file and set a breakpoint.

Navigate to the UI and confirm that the breakpoint is hit.

To end the debugging session, click the Dev Mode Off bookmark.

After changing the client side code:

Hitting F5 in the browser only reloads the last compile output, without
recompiling.

To reflect your changes in the debug session, click Dev Mode On then Compile.

Running GWT Debug Mode for Gerrit plugins

A Gerrit plugin can expose GWT module and its implementation can be inspected
in the SDM debug session.

codeserver needs two additional inputs to expose the plugin module in the SDM
debug session: the module name and the source folder location. For example the
module name and source folder of cookbook-plugin should be added in the local
copy of the gerrit_gwt_debug configuration: