blob: 5f69cd3d2b404f87ca0efb5505047e453d2b8e72 [file] [log] [blame]
Marian Harbachebeb1542019-12-13 10:42:46 +01001:linkattrs:
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08002= Gerrit Code Review - Eclipse Setup
Shawn O. Pearced2b73db2009-01-09 11:55:47 -08003
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -08004This document is about configuring Gerrit Code Review into an
David Ostrovsky7163dac2017-07-29 06:49:38 +02005Eclipse workspace for development.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -08006
Marco Millerf0b7ed82020-01-08 17:18:45 -05007Java 8 or later SDK is required.
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -08008
David Pursehouse2b16f6a2015-08-28 09:38:50 +09009[[setup]]
10== Project Setup
11
Marian Harbach34253372019-12-10 18:01:31 +010012In your Eclipse installation's link:https://wiki.eclipse.org/Eclipse.ini[`eclipse.ini`,role=external,window=_blank] file,
Eryk Szymanski6c5e6432017-04-24 10:32:52 +020013add the following line in the `vmargs` section:
David Pursehousec20dff22015-08-28 09:41:14 +090014
15----
16 -DmaxCompiledUnitsAtOnce=10000
17----
18
19Without this setting, annotation processing does not work reliably and the
20build is likely to fail with errors like:
21
22----
23 Could not write generated class ... javax.annotation.processing.FilerException: Source file already created
24----
25
David Pursehouse1023b262016-08-19 16:26:43 +090026and
27
28----
29 AutoAnnotation_Commands_named cannot be resolved to a type
30----
31
Eryk Szymanski49c76f52017-04-24 10:12:01 +020032First, generate the Eclipse project by running the `tools/eclipse/project.py` script.
33Then, in Eclipse, choose 'Import existing project' and select the `gerrit` project
David Pursehouse2b16f6a2015-08-28 09:38:50 +090034from the current working directory.
35
David Ostrovskyfdbfcad2016-11-15 06:35:29 -080036Expand the `gerrit` project, right-click on the `eclipse-out` folder, select
David Pursehouse2b16f6a2015-08-28 09:38:50 +090037'Properties', and then under 'Attributes' check 'Derived'.
38
39Note that if you make any changes in the project configuration
40that get saved to the `.project` file, for example adding Resource
41Filters on a folder, they will be overwritten the next time you run
42`tools/eclipse/project.py`.
43
Sven Selberg4076e822017-12-21 15:41:02 +010044=== Eclipse project with custom plugins ===
45
46To add custom plugins to the eclipse project add them to `tools/bzl/plugins.bzl`
47the same way you would when
48link:dev-build-plugins.html#_bundle_custom_plugin_in_release_war[bundling in release.war]
49and run `tools/eclipse/project.py`.
50
David Ostrovsky8aae31c2018-06-25 23:45:15 +020051[[Newer Java versions]]
52
53Java 9 and later are supported, but some adjustments must be done, because
54Java 8 is still the default:
55
56* Add JRE, e.g.: directory: /usr/lib64/jvm/java-9-openjdk, name: java-9-openjdk-9
Marco Miller0b7e9982019-11-01 13:29:08 -040057* Change execution environment for gerrit project to: JavaSE-9 (java-9-openjdk-9)
David Ostrovsky8aae31c2018-06-25 23:45:15 +020058* Check that compiler compliance level in gerrit project is set to: 9
David Pursehouse2b16f6a2015-08-28 09:38:50 +090059
Martin Fick081fa512011-08-12 11:22:45 -060060[[Formatting]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080061== Code Formatter Settings
Shawn O. Pearcee89544b2009-04-28 07:59:44 -070062
David Ostrovsky248b7092017-02-09 22:13:44 +010063To format source code, Gerrit uses the
Marian Harbach34253372019-12-10 18:01:31 +010064link:https://github.com/google/google-java-format[`google-java-format`,role=external,window=_blank]
Dave Borowitz3efa1052019-01-28 07:21:29 -080065tool (version 1.7), which automatically formats code to follow the
Marco Millerd71da9b2019-11-22 15:00:46 -050066style guide. See link:dev-crafting-changes.html#style[Code Style] for the
David Ostrovsky248b7092017-02-09 22:13:44 +010067instruction how to set up command line tool that uses this formatter.
68The Eclipse plugin is provided that allows to format with the same
69formatter from within the Eclipse IDE. See
Marian Harbach34253372019-12-10 18:01:31 +010070link:https://github.com/google/google-java-format#eclipse[Eclipse plugin,role=external,window=_blank]
David Ostrovsky248b7092017-02-09 22:13:44 +010071for details how to install it. It's important to use the same plugin version
72as the `google-java-format` script.
Shawn O. Pearcee89544b2009-04-28 07:59:44 -070073
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080074== Site Initialization
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080075
David Ostrovskydcee5722013-05-15 00:10:55 +020076Build once on the command line with
David Ostrovskyfdbfcad2016-11-15 06:35:29 -080077link:dev-bazel.html#build[Bazel] and then follow
David Pursehouse6de7ee22013-05-20 11:08:51 +090078link:dev-readme.html#init[Site Initialization] in the
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080079Developer Setup guide to configure a local site for testing.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080080
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080081
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080082== Testing
Shawn O. Pearce8d2f1842009-05-13 07:59:04 -070083
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080084=== Running the Daemon
Shawn O. Pearce8d2f1842009-05-13 07:59:04 -070085
David Pursehouse584af672013-05-20 11:15:18 +090086Duplicate the existing launch configuration:
Shawn O. Pearce8d2f1842009-05-13 07:59:04 -070087
David Pursehouse44eed242015-01-08 11:42:35 +090088* In Eclipse select Run -> Debug Configurations ...
Shawn Pearcecda21212013-11-28 20:49:42 -080089* Java Application -> `gerrit_daemon`
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080090* Right click, Duplicate
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080091* Modify the name to be unique.
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080092* Switch to Arguments tab.
Shawn O. Pearce955d00e2009-12-19 13:38:19 -080093* Edit the `-d` program argument flag to match the path used during
David Pursehouse44eed242015-01-08 11:42:35 +090094 'init'. The template launch configuration resolves to `../gerrit_testsite`
Shawn O. Pearce955d00e2009-12-19 13:38:19 -080095 since that is what the documentation recommends.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080096
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080097* Switch to Common tab.
98* Change Save as to be Local file.
David Pursehouse3800abd2013-05-08 09:24:29 +010099* Close the Debug Configurations dialog and save the changes when prompted.
Shawn O. Pearce06b48c32009-05-10 16:21:05 -0700100
Shawn O. Pearce5500e692009-05-28 15:55:01 -0700101GERRIT
102------
103Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700104
105SEARCHBOX
106---------