blob: b7c111f6d7efcf1fd99a0cc5f91da041d5ac4cd5 [file] [log] [blame]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08001= Gerrit Code Review - Developer Setup
Shawn O. Pearced2b73db2009-01-09 11:55:47 -08002
David Ostrovskyfdbfcad2016-11-15 06:35:29 -08003Google Bazel is needed to compile the code, and an SQL database to
David Ostrovskydcee5722013-05-15 00:10:55 +02004house the review metadata. H2 is recommended for development
5databases, as it requires no external server process.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -08006
David Pursehousefec58792013-05-10 15:34:02 +01007
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08008== Getting the Source
Shawn O. Pearced2b73db2009-01-09 11:55:47 -08009
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080010Create a new client workspace:
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080011
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080012----
David Pursehouse4f2be532013-05-09 13:47:17 +010013 git clone --recursive https://gerrit.googlesource.com/gerrit
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080014 cd gerrit
15----
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080016
David Pursehouse4f2be532013-05-09 13:47:17 +010017The `--recursive` option is needed on `git clone` to ensure that
18the core plugins, which are included as git submodules, are also
19cloned.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080020
Alice Kober-Sotzek4b92e042016-11-25 10:54:30 +010021[[compile_project]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080022== Compiling
David Pursehouse6de7ee22013-05-20 11:08:51 +090023
David Ostrovskyfdbfcad2016-11-15 06:35:29 -080024Please refer to <<dev-bazel#,Building with Bazel>>.
David Pursehouse6de7ee22013-05-20 11:08:51 +090025
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080026== Switching between branches
David Pursehoused106c8e2013-12-13 15:03:02 +090027
28When switching between branches with `git checkout`, be aware that
29submodule revisions are not altered. This may result in the wrong
30plugin revisions being present, unneeded plugins being present, or
31expected plugins being missing.
32
33After switching branches, make sure the submodules are at the correct
34revisions for the new branch with the commands:
35
36----
37 git submodule update
38 git clean -fdx
39----
40
Alice Kober-Sotzek4b92e042016-11-25 10:54:30 +010041CAUTION: If you decide to store your Eclipse/IntelliJ project files in the
42Gerrit source directories, executing `git clean -fdx` will remove them and hence
43screw up your project.
44
David Pursehoused106c8e2013-12-13 15:03:02 +090045
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080046== Configuring Eclipse
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080047
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080048To use the Eclipse IDE for development, please see
David Pursehousefec58792013-05-10 15:34:02 +010049link:dev-eclipse.html[Eclipse Setup].
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080050
David Ostrovskyfdbfcad2016-11-15 06:35:29 -080051For details on how to configure the Eclipse workspace with Bazel,
52refer to: link:dev-bazel.html#eclipse[Eclipse integration with Bazel].
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080053
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080054
Urs Wolferc0948bd2014-04-27 21:16:25 +020055== Configuring IntelliJ IDEA
56
Alice Kober-Sotzekd9da89f2016-11-25 12:02:18 +010057Please refer to <<dev-intellij#,IntelliJ Setup>> for detailed
Alice Kober-Sotzek4b92e042016-11-25 10:54:30 +010058instructions.
59
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080060== Mac OS X
David Pursehousefec58792013-05-10 15:34:02 +010061
Khai Doea9e4b72014-03-30 07:43:31 -070062On Mac OS X ensure "Java For Mac OS X 10.5 Update 4" (or later) has
63been installed, and that `JAVA_HOME` is set to the
64link:install.html#Requirements[required Java version].
Shawn O. Pearce461c2cc2009-02-25 09:09:31 -080065
Khai Doea9e4b72014-03-30 07:43:31 -070066Java installations can typically be found in
67"/System/Library/Frameworks/JavaVM.framework/Versions".
68
69You can check the installed Java version by running `java -version` in
70the terminal.
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080071
72[[init]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080073== Site Initialization
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080074
Alice Kober-Sotzek4b92e042016-11-25 10:54:30 +010075After compiling <<compile_project,(above)>>, run Gerrit's 'init' command to
76create a testing site for development use:
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080077
Alice Kober-Sotzek4b92e042016-11-25 10:54:30 +010078----
79 $(bazel info output_base)/external/local_jdk/bin/java \
80 -jar bazel-bin/gerrit.war init -d ../gerrit_testsite
81----
82
83[[special_bazel_java_version]]
84NOTE: You must use the same Java version that Bazel used for the build.
85This Java version is available at
86`$(bazel info output_base)/external/local_jdk/bin/java`.
87
Aaron Gable5eab7202016-10-12 11:24:06 -070088During initialization, make two changes to the default settings:
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080089
Aaron Gable5eab7202016-10-12 11:24:06 -070090* Change the listen addresses from '*' to 'localhost' to prevent outside
91 connections from contacting the development instance; and
92* Change the auth type from 'OPENID' to 'DEVELOPMENT_BECOME_ANY_ACCOUNT' to
93 allow yourself to create and act as arbitrary test accounts on your
94 development instance.
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080095
Aaron Gable5eab7202016-10-12 11:24:06 -070096Continue through init until it completes. The daemon will automatically start in
97the background and a web browser will launch to the start page. From here you
98can sign in as the account created during init, register additional accounts,
99create projects, and more.
100
101When you want to shut down the daemon, simply run:
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800102
103----
David Pursehouse9db23782013-12-17 11:59:22 +0900104 ../gerrit_testsite/bin/gerrit.sh stop
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800105----
106
107
Aaron Gable5eab7202016-10-12 11:24:06 -0700108[[localdev]]
109== Working with the Local Server
110
111If you need to create additional accounts on your development instance, click
112'become' in the upper right corner, select 'Switch User', and then register
113a new account.
114
115Use the `ssh` protocol to clone from and push to the local server. For
116example, to clone a repository that you've created through the admin
117interface, run:
118
119----
120git clone ssh://username@localhost:29418/projectname
121----
122
123Then you'll be able to create changes the same way users do, with
124
125----
126git push origin HEAD:refs/for/master
127----
128
129
130
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800131== Testing
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800132
David Pursehousefec58792013-05-10 15:34:02 +0100133
David Pursehouse5861a9a2013-05-15 10:25:19 +0900134[[tests]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800135=== Running the Acceptance Tests
Edwin Kempin4a3fc3f2013-02-27 15:18:43 +0100136
137Gerrit has a set of integration tests that test the Gerrit daemon via
138REST, SSH and the git protocol.
139
140A new review site is created for each test and the Gerrit daemon is
141started on that site. When the test has finished the Gerrit daemon is
142shutdown.
143
David Ostrovskyfdbfcad2016-11-15 06:35:29 -0800144For instructions on running the integration tests with Bazel,
145please refer to: <<dev-bazel#tests,Running Unit Tests with Bazel>>.
Edwin Kempin4a3fc3f2013-02-27 15:18:43 +0100146
Alice Kober-Sotzekd9da89f2016-11-25 12:02:18 +0100147[[run_daemon]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800148=== Running the Daemon
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800149
150The daemon can be directly launched from the build area, without
151copying to the test site:
152
Alice Kober-Sotzek4b92e042016-11-25 10:54:30 +0100153----
154 $(bazel info output_base)/external/local_jdk/bin/java \
Han-Wen Nienhuys0c93bc82017-01-19 15:26:42 +0100155 -jar bazel-bin/gerrit.war daemon -d ../gerrit_testsite \
156 --console-log
Alice Kober-Sotzek4b92e042016-11-25 10:54:30 +0100157----
158
159NOTE: Please refer to <<special_bazel_java_version,this explanation>>
160for details why using `java -jar` isn't sufficient.
161
Alice Kober-Sotzek485a5ff2017-03-02 13:20:32 +0100162If you want to debug the Gerrit server of this test site, you can open a debug
163port (for example port 5005) by inserting
164
165----
166-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
167----
168
169directly after `-jar` of the previous command. Please refer to
170<<dev-intellij#remote-debug,Debugging a remote Gerrit server>> for instructions
171of how to attach IntelliJ.
Alice Kober-Sotzek4b92e042016-11-25 10:54:30 +0100172
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800173=== Running the Daemon with Gerrit Inspector
Marcin Cieślaked612fb2012-04-17 16:24:34 +0000174
175link:dev-inspector.html[Gerrit Inspector] is an interactive scriptable
176environment to inspect and modify internal state of the system.
177
178This environment is available on the system console after
179the system starts. Leaving the Inspector will shutdown the Gerrit
180instance.
181
182The environment allows interactive work as well as running of
183Python scripts for troubleshooting.
184
185Gerrit Inspect can be started by adding '-s' option to the
186command used to launch the daemon:
187
Alice Kober-Sotzek4b92e042016-11-25 10:54:30 +0100188----
189 $(bazel info output_base)/external/local_jdk/bin/java \
190 -jar bazel-bin/gerrit.war daemon -d ../gerrit_testsite -s
191----
192
193NOTE: Please refer to <<special_bazel_java_version,this explanation>>
194for details why using `java -jar` isn't sufficient.
195
Marcin Cieślaked612fb2012-04-17 16:24:34 +0000196Gerrit Inspector examines Java libraries first, then loads
197its initialization scripts and then starts a command line
198prompt on the console:
199
200----
201 Welcome to the Gerrit Inspector
202 Enter help() to see the above again, EOF to quit and stop Gerrit
203 Jython 2.5.2 (Release_2_5_2:7206, Mar 2 2011, 23:12:06)
204 [OpenJDK 64-Bit Server VM (Sun Microsystems Inc.)] on java1.6.0 running for Gerrit 2.3-rc0-163-g01967ef
205 >>>
206----
207
208With the Inspector enabled Gerrit can be used normally and all
209interfaces (HTTP, SSH etc.) are available.
210
211Care must be taken not to modify internal state of the system
212when using the Inspector.
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800213
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800214=== Querying the Database
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800215
216The embedded H2 database can be queried and updated from the
217command line. If the daemon is not currently running:
218
Alice Kober-Sotzek4b92e042016-11-25 10:54:30 +0100219----
220 $(bazel info output_base)/external/local_jdk/bin/java \
221 -jar bazel-bin/gerrit.war gsql -d ../gerrit_testsite -s
222----
223
224NOTE: Please refer to <<special_bazel_java_version,this explanation>>
225for details why using `java -jar` isn't sufficient.
226
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800227Or, if it is running and the database is in use, connect over SSH
228using an administrator user account:
229
230----
231 ssh -p 29418 user@localhost gerrit gsql
232----
233
234
Edwin Kempin57fa1792013-03-27 10:43:41 +0100235[[debug-javascript]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800236=== Debugging JavaScript
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800237
Shawn Pearced07a6222013-03-21 00:11:45 -0700238When debugging browser specific issues add `?dbg=1` to the URL so the
239resulting JavaScript more closely matches the Java sources. The debug
240pages use the GWT pretty format, where function and variable names
241match the Java sources.
242
243----
244 http://localhost:8080/?dbg=1
245----
246
Shawn O. Pearce6ddb6ca2009-09-18 18:10:31 -0700247
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800248== Client-Server RPC
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800249
250The client-server RPC implementation is gwtjsonrpc, not the stock RPC
251system that comes with GWT. This buys us automatic XSRF protection.
252It also makes all of the messages readable and writable by any JSON
253implementation, facilitating "mashups" and 3rd party clients.
254
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800255The programming API is virtually identical, except service interfaces
256extend RemoteJsonService instead of RemoteService.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800257
258
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800259== Why GWT?
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800260
261We like it. Plus we can write Java code once and run it both in
Shawn O. Pearcee2bd1b12009-08-20 11:08:32 -0700262the browser and on the server side.
Shawn O. Pearce5500e692009-05-28 15:55:01 -0700263
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800264
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800265== External Links
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800266
267Google Web Toolkit:
268
269* http://code.google.com/webtoolkit/download.html[Download]
270
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800271Apache SSHD:
272
273* http://mina.apache.org/sshd/[SSHD]
274
275H2:
276
277* http://www.h2database.com/[H2]
278* http://www.h2database.com/html/grammar.html[SQL Reference]
279
280PostgreSQL:
281
282* http://www.postgresql.org/download/[Download]
283* http://www.postgresql.org/docs/[Documentation]
284
285
Shawn O. Pearce5500e692009-05-28 15:55:01 -0700286GERRIT
287------
288Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700289
290SEARCHBOX
291---------