Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 1 | = Gerrit Code Review - Eclipse Setup |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 2 | |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 3 | This document is about configuring Gerrit Code Review into an |
David Ostrovsky | 7163dac | 2017-07-29 06:49:38 +0200 | [diff] [blame] | 4 | Eclipse workspace for development. |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 5 | |
David Ostrovsky | 7163dac | 2017-07-29 06:49:38 +0200 | [diff] [blame] | 6 | Java 8 or later SDK is require |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 7 | |
David Pursehouse | 2b16f6a | 2015-08-28 09:38:50 +0900 | [diff] [blame] | 8 | [[setup]] |
| 9 | == Project Setup |
| 10 | |
Eryk Szymanski | 6c5e643 | 2017-04-24 10:32:52 +0200 | [diff] [blame] | 11 | In your Eclipse installation's link:https://wiki.eclipse.org/Eclipse.ini[`eclipse.ini`] file, |
| 12 | add the following line in the `vmargs` section: |
David Pursehouse | c20dff2 | 2015-08-28 09:41:14 +0900 | [diff] [blame] | 13 | |
| 14 | ---- |
| 15 | -DmaxCompiledUnitsAtOnce=10000 |
| 16 | ---- |
| 17 | |
| 18 | Without this setting, annotation processing does not work reliably and the |
| 19 | build is likely to fail with errors like: |
| 20 | |
| 21 | ---- |
| 22 | Could not write generated class ... javax.annotation.processing.FilerException: Source file already created |
| 23 | ---- |
| 24 | |
David Pursehouse | 1023b26 | 2016-08-19 16:26:43 +0900 | [diff] [blame] | 25 | and |
| 26 | |
| 27 | ---- |
| 28 | AutoAnnotation_Commands_named cannot be resolved to a type |
| 29 | ---- |
| 30 | |
Eryk Szymanski | 49c76f5 | 2017-04-24 10:12:01 +0200 | [diff] [blame] | 31 | First, generate the Eclipse project by running the `tools/eclipse/project.py` script. |
| 32 | Then, in Eclipse, choose 'Import existing project' and select the `gerrit` project |
David Pursehouse | 2b16f6a | 2015-08-28 09:38:50 +0900 | [diff] [blame] | 33 | from the current working directory. |
| 34 | |
David Ostrovsky | fdbfcad | 2016-11-15 06:35:29 -0800 | [diff] [blame] | 35 | Expand the `gerrit` project, right-click on the `eclipse-out` folder, select |
David Pursehouse | 2b16f6a | 2015-08-28 09:38:50 +0900 | [diff] [blame] | 36 | 'Properties', and then under 'Attributes' check 'Derived'. |
| 37 | |
| 38 | Note that if you make any changes in the project configuration |
| 39 | that get saved to the `.project` file, for example adding Resource |
| 40 | Filters on a folder, they will be overwritten the next time you run |
| 41 | `tools/eclipse/project.py`. |
| 42 | |
Sven Selberg | 4076e82 | 2017-12-21 15:41:02 +0100 | [diff] [blame] | 43 | === Eclipse project with custom plugins === |
| 44 | |
| 45 | To add custom plugins to the eclipse project add them to `tools/bzl/plugins.bzl` |
| 46 | the same way you would when |
| 47 | link:dev-build-plugins.html#_bundle_custom_plugin_in_release_war[bundling in release.war] |
| 48 | and run `tools/eclipse/project.py`. |
| 49 | |
David Ostrovsky | 8aae31c | 2018-06-25 23:45:15 +0200 | [diff] [blame] | 50 | [[Newer Java versions]] |
| 51 | |
| 52 | Java 9 and later are supported, but some adjustments must be done, because |
| 53 | Java 8 is still the default: |
| 54 | |
| 55 | * Add JRE, e.g.: directory: /usr/lib64/jvm/java-9-openjdk, name: java-9-openjdk-9 |
Marco Miller | 0b7e998 | 2019-11-01 13:29:08 -0400 | [diff] [blame] | 56 | * Change execution environment for gerrit project to: JavaSE-9 (java-9-openjdk-9) |
David Ostrovsky | 8aae31c | 2018-06-25 23:45:15 +0200 | [diff] [blame] | 57 | * Check that compiler compliance level in gerrit project is set to: 9 |
David Pursehouse | 2b16f6a | 2015-08-28 09:38:50 +0900 | [diff] [blame] | 58 | |
Martin Fick | 081fa51 | 2011-08-12 11:22:45 -0600 | [diff] [blame] | 59 | [[Formatting]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 60 | == Code Formatter Settings |
Shawn O. Pearce | e89544b | 2009-04-28 07:59:44 -0700 | [diff] [blame] | 61 | |
David Ostrovsky | 248b709 | 2017-02-09 22:13:44 +0100 | [diff] [blame] | 62 | To format source code, Gerrit uses the |
| 63 | link:https://github.com/google/google-java-format[`google-java-format`] |
Dave Borowitz | 3efa105 | 2019-01-28 07:21:29 -0800 | [diff] [blame] | 64 | tool (version 1.7), which automatically formats code to follow the |
David Ostrovsky | 248b709 | 2017-02-09 22:13:44 +0100 | [diff] [blame] | 65 | style guide. See link:dev-contributing.html#style[Code Style] for the |
| 66 | instruction how to set up command line tool that uses this formatter. |
| 67 | The Eclipse plugin is provided that allows to format with the same |
| 68 | formatter from within the Eclipse IDE. See |
| 69 | link:https://github.com/google/google-java-format#eclipse[Eclipse plugin] |
| 70 | for details how to install it. It's important to use the same plugin version |
| 71 | as the `google-java-format` script. |
Shawn O. Pearce | e89544b | 2009-04-28 07:59:44 -0700 | [diff] [blame] | 72 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 73 | == Site Initialization |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 74 | |
David Ostrovsky | dcee572 | 2013-05-15 00:10:55 +0200 | [diff] [blame] | 75 | Build once on the command line with |
David Ostrovsky | fdbfcad | 2016-11-15 06:35:29 -0800 | [diff] [blame] | 76 | link:dev-bazel.html#build[Bazel] and then follow |
David Pursehouse | 6de7ee2 | 2013-05-20 11:08:51 +0900 | [diff] [blame] | 77 | link:dev-readme.html#init[Site Initialization] in the |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 78 | Developer Setup guide to configure a local site for testing. |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 79 | |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 80 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 81 | == Testing |
Shawn O. Pearce | 8d2f184 | 2009-05-13 07:59:04 -0700 | [diff] [blame] | 82 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 83 | === Running the Daemon |
Shawn O. Pearce | 8d2f184 | 2009-05-13 07:59:04 -0700 | [diff] [blame] | 84 | |
David Pursehouse | 584af67 | 2013-05-20 11:15:18 +0900 | [diff] [blame] | 85 | Duplicate the existing launch configuration: |
Shawn O. Pearce | 8d2f184 | 2009-05-13 07:59:04 -0700 | [diff] [blame] | 86 | |
David Pursehouse | 44eed24 | 2015-01-08 11:42:35 +0900 | [diff] [blame] | 87 | * In Eclipse select Run -> Debug Configurations ... |
Shawn Pearce | cda2121 | 2013-11-28 20:49:42 -0800 | [diff] [blame] | 88 | * Java Application -> `gerrit_daemon` |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 89 | * Right click, Duplicate |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 90 | * Modify the name to be unique. |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 91 | * Switch to Arguments tab. |
Shawn O. Pearce | 955d00e | 2009-12-19 13:38:19 -0800 | [diff] [blame] | 92 | * Edit the `-d` program argument flag to match the path used during |
David Pursehouse | 44eed24 | 2015-01-08 11:42:35 +0900 | [diff] [blame] | 93 | 'init'. The template launch configuration resolves to `../gerrit_testsite` |
Shawn O. Pearce | 955d00e | 2009-12-19 13:38:19 -0800 | [diff] [blame] | 94 | since that is what the documentation recommends. |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 95 | |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 96 | * Switch to Common tab. |
| 97 | * Change Save as to be Local file. |
David Pursehouse | 3800abd | 2013-05-08 09:24:29 +0100 | [diff] [blame] | 98 | * Close the Debug Configurations dialog and save the changes when prompted. |
Shawn O. Pearce | 06b48c3 | 2009-05-10 16:21:05 -0700 | [diff] [blame] | 99 | |
Shawn O. Pearce | 5500e69 | 2009-05-28 15:55:01 -0700 | [diff] [blame] | 100 | GERRIT |
| 101 | ------ |
| 102 | Part of link:index.html[Gerrit Code Review] |
Yuxuan 'fishy' Wang | 99cb68d | 2013-10-31 17:26:00 -0700 | [diff] [blame] | 103 | |
| 104 | SEARCHBOX |
| 105 | --------- |