blob: 4fa542d456ca69d7ca26b460b5ccbbd647d477bd [file] [log] [blame]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08001= Gerrit Code Review - Eclipse Setup
Shawn O. Pearced2b73db2009-01-09 11:55:47 -08002
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -08003This document is about configuring Gerrit Code Review into an
Shawn O. Pearce5eaf5d92009-12-21 15:16:10 -08004Eclipse workspace for development and debugging with GWT.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -08005
Shawn O. Pearce5eaf5d92009-12-21 15:16:10 -08006Java 6 or later SDK is also required to run GWT's compiler and
7runtime debugging environment.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -08008
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -08009
David Pursehouse2b16f6a2015-08-28 09:38:50 +090010[[setup]]
11== Project Setup
12
David Pursehousec20dff22015-08-28 09:41:14 +090013In your Eclipse installation's `eclipse.ini` file, add the following line in
14the `vmargs` section:
15
16----
17 -DmaxCompiledUnitsAtOnce=10000
18----
19
20Without this setting, annotation processing does not work reliably and the
21build 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 Pursehouse1023b262016-08-19 16:26:43 +090027and
28
29----
30 AutoAnnotation_Commands_named cannot be resolved to a type
31----
32
David Pursehouse2b16f6a2015-08-28 09:38:50 +090033In Eclipse, choose 'Import existing project' and select the `gerrit` project
34from the current working directory.
35
36Expand the `gerrit` project, right-click on the `buck-out` folder, select
37'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
44
Martin Fick081fa512011-08-12 11:22:45 -060045[[Formatting]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080046== Code Formatter Settings
Shawn O. Pearcee89544b2009-04-28 07:59:44 -070047
Shawn O. Pearce44671f52009-11-07 12:55:26 -080048Import `tools/GoogleFormat.xml` using Window -> Preferences ->
49Java -> Code Style -> Formatter -> Import...
Shawn O. Pearcee89544b2009-04-28 07:59:44 -070050
51This will define the 'Google Format' profile, which the project
52settings prefer when formatting source code.
53
54
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080055== Site Initialization
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080056
David Ostrovskydcee5722013-05-15 00:10:55 +020057Build once on the command line with
58link:dev-buck.html#build[Buck] and then follow
David Pursehouse6de7ee22013-05-20 11:08:51 +090059link:dev-readme.html#init[Site Initialization] in the
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080060Developer Setup guide to configure a local site for testing.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080061
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080062
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080063== Testing
Shawn O. Pearce8d2f1842009-05-13 07:59:04 -070064
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080065=== Running the Daemon
Shawn O. Pearce8d2f1842009-05-13 07:59:04 -070066
David Pursehouse584af672013-05-20 11:15:18 +090067Duplicate the existing launch configuration:
Shawn O. Pearce8d2f1842009-05-13 07:59:04 -070068
David Pursehouse44eed242015-01-08 11:42:35 +090069* In Eclipse select Run -> Debug Configurations ...
Shawn Pearcecda21212013-11-28 20:49:42 -080070* Java Application -> `gerrit_daemon`
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080071* Right click, Duplicate
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080072* Modify the name to be unique.
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080073* Switch to Arguments tab.
Shawn O. Pearce955d00e2009-12-19 13:38:19 -080074* Edit the `-d` program argument flag to match the path used during
David Pursehouse44eed242015-01-08 11:42:35 +090075 'init'. The template launch configuration resolves to `../gerrit_testsite`
Shawn O. Pearce955d00e2009-12-19 13:38:19 -080076 since that is what the documentation recommends.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080077
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080078* Switch to Common tab.
79* Change Save as to be Local file.
David Pursehouse3800abd2013-05-08 09:24:29 +010080* Close the Debug Configurations dialog and save the changes when prompted.
Shawn O. Pearce06b48c32009-05-10 16:21:05 -070081
Shawn O. Pearce06b48c32009-05-10 16:21:05 -070082
Dave Borowitz9c4a4702014-08-15 14:35:37 -070083=== Running GWT Debug Mode
Shawn O. Pearce06b48c32009-05-10 16:21:05 -070084
David Pursehouse44eed242015-01-08 11:42:35 +090085The `gerrit_gwt_debug` launch configuration uses GWT's
Dave Borowitz9c4a4702014-08-15 14:35:37 -070086link:http://www.gwtproject.org/articles/superdevmode.html[Super Dev Mode].
Shawn O. Pearce955d00e2009-12-19 13:38:19 -080087
David Pursehouse44eed242015-01-08 11:42:35 +090088* Make a local copy of the `gerrit_gwt_debug` configuration, using the
89process 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 Ostrovsky12968f22014-06-03 11:14:57 +020092
David Pursehouse44eed242015-01-08 11:42:35 +090093** Open the link:http://localhost:9876/[codeserver URL] and add the `Dev Mode On`
94and `Dev Mode Off` bookmarklet to your bookmark bar.
95
96** Activate the source maps feature in your browser. Refer to the
97link:https://developer.chrome.com/devtools/docs/javascript-debugging#source-maps[
98Chrome] and
99link:https://developer.mozilla.org/en-US/docs/Tools/Debugger#Use_a_source_map[
100Firefox] 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
106as 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
114recompiling.
115* To reflect your changes in the debug session, click `Dev Mode On` then `Compile`.
David Ostrovsky12968f22014-06-03 11:14:57 +0200116
David Ostrovsky94aab1b2015-06-24 08:33:44 +0200117
118=== Running GWT Debug Mode for Gerrit plugins
119
120A Gerrit plugin can expose GWT module and its implementation can be inspected
121in the SDM debug session.
122
123`codeserver` needs two additional inputs to expose the plugin module in the SDM
124debug session: the module name and the source folder location. For example the
125module name and source folder of `cookbook-plugin` should be added in the local
126copy 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
134After doing that, both the Gerrit core and plugin GWT modules can be activated
135during SDM (debug session)[http://imgur.com/HFXZ5No].
136
Shawn O. Pearce5500e692009-05-28 15:55:01 -0700137GERRIT
138------
139Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700140
141SEARCHBOX
142---------