| 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 |
| Shawn O. Pearce | 5eaf5d9 | 2009-12-21 15:16:10 -0800 | [diff] [blame] | 4 | Eclipse workspace for development and debugging with GWT. |
| Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 5 | |
| Shawn O. Pearce | 5eaf5d9 | 2009-12-21 15:16:10 -0800 | [diff] [blame] | 6 | Java 6 or later SDK is also required to run GWT's compiler and |
| 7 | runtime debugging environment. |
| Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 8 | |
| Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 9 | |
| David Pursehouse | 2b16f6a | 2015-08-28 09:38:50 +0900 | [diff] [blame] | 10 | [[setup]] |
| 11 | == Project Setup |
| 12 | |
| David Pursehouse | c20dff2 | 2015-08-28 09:41:14 +0900 | [diff] [blame] | 13 | In your Eclipse installation's `eclipse.ini` file, add the following line in |
| 14 | the `vmargs` section: |
| 15 | |
| 16 | ---- |
| 17 | -DmaxCompiledUnitsAtOnce=10000 |
| 18 | ---- |
| 19 | |
| 20 | Without this setting, annotation processing does not work reliably and the |
| 21 | build is likely to fail with errors like: |
| 22 | |
| 23 | ---- |
| 24 | Could not write generated class ... javax.annotation.processing.FilerException: Source file already created |
| 25 | ---- |
| 26 | |
| David Pursehouse | 1023b26 | 2016-08-19 16:26:43 +0900 | [diff] [blame] | 27 | and |
| 28 | |
| 29 | ---- |
| 30 | AutoAnnotation_Commands_named cannot be resolved to a type |
| 31 | ---- |
| 32 | |
| David Pursehouse | 2b16f6a | 2015-08-28 09:38:50 +0900 | [diff] [blame] | 33 | In Eclipse, choose 'Import existing project' and select the `gerrit` project |
| 34 | from the current working directory. |
| 35 | |
| 36 | Expand the `gerrit` project, right-click on the `buck-out` folder, select |
| 37 | 'Properties', and then under 'Attributes' check 'Derived'. |
| 38 | |
| 39 | Note that if you make any changes in the project configuration |
| 40 | that get saved to the `.project` file, for example adding Resource |
| 41 | Filters on a folder, they will be overwritten the next time you run |
| 42 | `tools/eclipse/project.py`. |
| 43 | |
| 44 | |
| Martin Fick | 081fa51 | 2011-08-12 11:22:45 -0600 | [diff] [blame] | 45 | [[Formatting]] |
| Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 46 | == Code Formatter Settings |
| Shawn O. Pearce | e89544b | 2009-04-28 07:59:44 -0700 | [diff] [blame] | 47 | |
| Shawn O. Pearce | 44671f5 | 2009-11-07 12:55:26 -0800 | [diff] [blame] | 48 | Import `tools/GoogleFormat.xml` using Window -> Preferences -> |
| 49 | Java -> Code Style -> Formatter -> Import... |
| Shawn O. Pearce | e89544b | 2009-04-28 07:59:44 -0700 | [diff] [blame] | 50 | |
| 51 | This will define the 'Google Format' profile, which the project |
| 52 | settings prefer when formatting source code. |
| 53 | |
| 54 | |
| Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 55 | == Site Initialization |
| Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 56 | |
| David Ostrovsky | dcee572 | 2013-05-15 00:10:55 +0200 | [diff] [blame] | 57 | Build once on the command line with |
| 58 | link:dev-buck.html#build[Buck] and then follow |
| David Pursehouse | 6de7ee2 | 2013-05-20 11:08:51 +0900 | [diff] [blame] | 59 | link:dev-readme.html#init[Site Initialization] in the |
| Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 60 | Developer Setup guide to configure a local site for testing. |
| Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 61 | |
| Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 62 | |
| Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 63 | == Testing |
| Shawn O. Pearce | 8d2f184 | 2009-05-13 07:59:04 -0700 | [diff] [blame] | 64 | |
| Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 65 | === Running the Daemon |
| Shawn O. Pearce | 8d2f184 | 2009-05-13 07:59:04 -0700 | [diff] [blame] | 66 | |
| David Pursehouse | 584af67 | 2013-05-20 11:15:18 +0900 | [diff] [blame] | 67 | Duplicate the existing launch configuration: |
| Shawn O. Pearce | 8d2f184 | 2009-05-13 07:59:04 -0700 | [diff] [blame] | 68 | |
| David Pursehouse | 44eed24 | 2015-01-08 11:42:35 +0900 | [diff] [blame] | 69 | * In Eclipse select Run -> Debug Configurations ... |
| Shawn Pearce | cda2121 | 2013-11-28 20:49:42 -0800 | [diff] [blame] | 70 | * Java Application -> `gerrit_daemon` |
| Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 71 | * Right click, Duplicate |
| Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 72 | * Modify the name to be unique. |
| Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 73 | * Switch to Arguments tab. |
| Shawn O. Pearce | 955d00e | 2009-12-19 13:38:19 -0800 | [diff] [blame] | 74 | * Edit the `-d` program argument flag to match the path used during |
| David Pursehouse | 44eed24 | 2015-01-08 11:42:35 +0900 | [diff] [blame] | 75 | 'init'. The template launch configuration resolves to `../gerrit_testsite` |
| Shawn O. Pearce | 955d00e | 2009-12-19 13:38:19 -0800 | [diff] [blame] | 76 | since that is what the documentation recommends. |
| Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 77 | |
| Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 78 | * Switch to Common tab. |
| 79 | * Change Save as to be Local file. |
| David Pursehouse | 3800abd | 2013-05-08 09:24:29 +0100 | [diff] [blame] | 80 | * Close the Debug Configurations dialog and save the changes when prompted. |
| Shawn O. Pearce | 06b48c3 | 2009-05-10 16:21:05 -0700 | [diff] [blame] | 81 | |
| Shawn O. Pearce | 06b48c3 | 2009-05-10 16:21:05 -0700 | [diff] [blame] | 82 | |
| Dave Borowitz | 9c4a470 | 2014-08-15 14:35:37 -0700 | [diff] [blame] | 83 | === Running GWT Debug Mode |
| Shawn O. Pearce | 06b48c3 | 2009-05-10 16:21:05 -0700 | [diff] [blame] | 84 | |
| David Pursehouse | 44eed24 | 2015-01-08 11:42:35 +0900 | [diff] [blame] | 85 | The `gerrit_gwt_debug` launch configuration uses GWT's |
| Dave Borowitz | 9c4a470 | 2014-08-15 14:35:37 -0700 | [diff] [blame] | 86 | link:http://www.gwtproject.org/articles/superdevmode.html[Super Dev Mode]. |
| Shawn O. Pearce | 955d00e | 2009-12-19 13:38:19 -0800 | [diff] [blame] | 87 | |
| David Pursehouse | 44eed24 | 2015-01-08 11:42:35 +0900 | [diff] [blame] | 88 | * Make a local copy of the `gerrit_gwt_debug` configuration, using the |
| 89 | process described for `gerrit_daemon` above. |
| 90 | * Launch the local copy of `gerrit_gwt_debug` from the Eclipse debug menu. |
| 91 | * If debugging GWT for the first time: |
| David Ostrovsky | 12968f2 | 2014-06-03 11:14:57 +0200 | [diff] [blame] | 92 | |
| David Pursehouse | 44eed24 | 2015-01-08 11:42:35 +0900 | [diff] [blame] | 93 | ** Open the link:http://localhost:9876/[codeserver URL] and add the `Dev Mode On` |
| 94 | and `Dev Mode Off` bookmarklet to your bookmark bar. |
| 95 | |
| 96 | ** Activate the source maps feature in your browser. Refer to the |
| 97 | link:https://developer.chrome.com/devtools/docs/javascript-debugging#source-maps[ |
| 98 | Chrome] and |
| 99 | link:https://developer.mozilla.org/en-US/docs/Tools/Debugger#Use_a_source_map[ |
| 100 | Firefox] developer documentation. |
| 101 | |
| 102 | * Load the link:http://localhost:8080[Gerrit page]. |
| 103 | * Open the source tab in developer tools. |
| 104 | * Click the `Dev Mode On` bookmark to incrementally recompile changed files. |
| 105 | * Select the `gerrit_ui` module to compile (the `Compile` button can also be used |
| 106 | as a bookmarklet). |
| 107 | * In the developer tools source tab, open a file and set a breakpoint. |
| 108 | * Navigate to the UI and confirm that the breakpoint is hit. |
| 109 | * To end the debugging session, click the `Dev Mode Off` bookmark. |
| 110 | |
| 111 | .After changing the client side code: |
| 112 | |
| 113 | * Hitting `F5` in the browser only reloads the last compile output, without |
| 114 | recompiling. |
| 115 | * To reflect your changes in the debug session, click `Dev Mode On` then `Compile`. |
| David Ostrovsky | 12968f2 | 2014-06-03 11:14:57 +0200 | [diff] [blame] | 116 | |
| David Ostrovsky | 94aab1b | 2015-06-24 08:33:44 +0200 | [diff] [blame] | 117 | |
| 118 | === Running GWT Debug Mode for Gerrit plugins |
| 119 | |
| 120 | A Gerrit plugin can expose GWT module and its implementation can be inspected |
| 121 | in the SDM debug session. |
| 122 | |
| 123 | `codeserver` needs two additional inputs to expose the plugin module in the SDM |
| 124 | debug session: the module name and the source folder location. For example the |
| 125 | module name and source folder of `cookbook-plugin` should be added in the local |
| 126 | copy of the `gerrit_gwt_debug` configuration: |
| 127 | |
| 128 | ---- |
| 129 | com.googlesource.gerrit.plugins.cookbook.HelloForm \ |
| 130 | -src ${resource_loc:/gerrit}/plugins/cookbook-plugin/src/main/java \ |
| 131 | -- --console-log [...] |
| 132 | ---- |
| 133 | |
| 134 | After doing that, both the Gerrit core and plugin GWT modules can be activated |
| 135 | during SDM (debug session)[http://imgur.com/HFXZ5No]. |
| 136 | |
| Shawn O. Pearce | 5500e69 | 2009-05-28 15:55:01 -0700 | [diff] [blame] | 137 | GERRIT |
| 138 | ------ |
| 139 | Part of link:index.html[Gerrit Code Review] |
| Yuxuan 'fishy' Wang | 99cb68d | 2013-10-31 17:26:00 -0700 | [diff] [blame] | 140 | |
| 141 | SEARCHBOX |
| 142 | --------- |