blob: bcf4a588a502ce7b1a313a830e1feb1440e1c4f4 [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 Ostrovskydcee5722013-05-15 00:10:55 +02003Facebook Buck is needed to compile the code, and an SQL database to
4house 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
David Pursehousefec58792013-05-10 15:34:02 +010021
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080022== Compiling
David Pursehouse6de7ee22013-05-20 11:08:51 +090023
David Pursehouse5d9ef412013-05-22 13:33:45 +090024For details on how to build the source code with Buck, refer to:
25link:dev-buck.html#build[Building on the command line with Buck].
David Pursehouse6de7ee22013-05-20 11:08:51 +090026
27
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080028== Switching between branches
David Pursehoused106c8e2013-12-13 15:03:02 +090029
30When switching between branches with `git checkout`, be aware that
31submodule revisions are not altered. This may result in the wrong
32plugin revisions being present, unneeded plugins being present, or
33expected plugins being missing.
34
35After switching branches, make sure the submodules are at the correct
36revisions for the new branch with the commands:
37
38----
39 git submodule update
40 git clean -fdx
41----
42
43
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080044== Configuring Eclipse
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080045
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080046To use the Eclipse IDE for development, please see
David Pursehousefec58792013-05-10 15:34:02 +010047link:dev-eclipse.html[Eclipse Setup].
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080048
David Pursehouse5d9ef412013-05-22 13:33:45 +090049For details on how to configure the Eclipse workspace with Buck,
50refer to: link:dev-buck.html#eclipse[Eclipse integration with Buck].
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080051
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080052
Urs Wolferc0948bd2014-04-27 21:16:25 +020053== Configuring IntelliJ IDEA
54
55To use IntelliJ IDEA for development, the easiest way is to follow
56Eclipse integration and then open it as Eclipse project in IDEA.
57You need the Eclipse plugin activated in IntelliJ IDEA.
58
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
75After compiling (above), run Gerrit's 'init' command to create a
76testing site for development use:
77
78----
David Pursehouse9db23782013-12-17 11:59:22 +090079 java -jar buck-out/gen/gerrit.war init -d ../gerrit_testsite
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080080----
81
82Accept defaults by pressing Enter until 'init' completes, or add
Yuxuan 'fishy' Wang77e15082013-12-09 15:43:25 -080083the '--batch' command line option to avoid them entirely. It is
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080084recommended to change the listen addresses from '*' to 'localhost' to
85prevent outside connections from contacting the development instance.
86
87The daemon will automatically start in the background and a web
88browser will launch to the start page, enabling login via OpenID.
89
90Shutdown the daemon after registering the administrator account
91through the web interface:
92
93----
David Pursehouse9db23782013-12-17 11:59:22 +090094 ../gerrit_testsite/bin/gerrit.sh stop
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080095----
96
97
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080098== Testing
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080099
David Pursehousefec58792013-05-10 15:34:02 +0100100
David Pursehouse5861a9a2013-05-15 10:25:19 +0900101[[tests]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800102=== Running the Acceptance Tests
Edwin Kempin4a3fc3f2013-02-27 15:18:43 +0100103
104Gerrit has a set of integration tests that test the Gerrit daemon via
105REST, SSH and the git protocol.
106
107A new review site is created for each test and the Gerrit daemon is
108started on that site. When the test has finished the Gerrit daemon is
109shutdown.
110
David Ostrovskydcee5722013-05-15 00:10:55 +0200111For instructions on running the integration tests with Buck,
David Pursehouse5861a9a2013-05-15 10:25:19 +0900112please refer to:
David Pursehouse5d9ef412013-05-22 13:33:45 +0900113link:dev-buck.html#tests[Running integration tests with Buck].
Edwin Kempin4a3fc3f2013-02-27 15:18:43 +0100114
Edwin Kempin4a3fc3f2013-02-27 15:18:43 +0100115
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800116=== Running the Daemon
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800117
118The daemon can be directly launched from the build area, without
119copying to the test site:
120
121----
David Pursehouse9db23782013-12-17 11:59:22 +0900122 java -jar buck-out/gen/gerrit.war daemon -d ../gerrit_testsite
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800123----
124
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800125=== Running the Daemon with Gerrit Inspector
Marcin Cieślaked612fb2012-04-17 16:24:34 +0000126
127link:dev-inspector.html[Gerrit Inspector] is an interactive scriptable
128environment to inspect and modify internal state of the system.
129
130This environment is available on the system console after
131the system starts. Leaving the Inspector will shutdown the Gerrit
132instance.
133
134The environment allows interactive work as well as running of
135Python scripts for troubleshooting.
136
137Gerrit Inspect can be started by adding '-s' option to the
138command used to launch the daemon:
139
140----
David Pursehouse9db23782013-12-17 11:59:22 +0900141 java -jar buck-out/gen/gerrit.war daemon -d ../gerrit_testsite -s
Marcin Cieślaked612fb2012-04-17 16:24:34 +0000142----
143
144Gerrit Inspector examines Java libraries first, then loads
145its initialization scripts and then starts a command line
146prompt on the console:
147
148----
149 Welcome to the Gerrit Inspector
150 Enter help() to see the above again, EOF to quit and stop Gerrit
151 Jython 2.5.2 (Release_2_5_2:7206, Mar 2 2011, 23:12:06)
152 [OpenJDK 64-Bit Server VM (Sun Microsystems Inc.)] on java1.6.0 running for Gerrit 2.3-rc0-163-g01967ef
153 >>>
154----
155
156With the Inspector enabled Gerrit can be used normally and all
157interfaces (HTTP, SSH etc.) are available.
158
159Care must be taken not to modify internal state of the system
160when using the Inspector.
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800161
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800162=== Querying the Database
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800163
164The embedded H2 database can be queried and updated from the
165command line. If the daemon is not currently running:
166
167----
David Pursehouse9db23782013-12-17 11:59:22 +0900168 java -jar buck-out/gen/gerrit.war gsql -d ../gerrit_testsite
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800169----
170
171Or, if it is running and the database is in use, connect over SSH
172using an administrator user account:
173
174----
175 ssh -p 29418 user@localhost gerrit gsql
176----
177
178
Edwin Kempin57fa1792013-03-27 10:43:41 +0100179[[debug-javascript]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800180=== Debugging JavaScript
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800181
Shawn Pearced07a6222013-03-21 00:11:45 -0700182When debugging browser specific issues add `?dbg=1` to the URL so the
183resulting JavaScript more closely matches the Java sources. The debug
184pages use the GWT pretty format, where function and variable names
185match the Java sources.
186
187----
188 http://localhost:8080/?dbg=1
189----
190
Shawn O. Pearce6ddb6ca2009-09-18 18:10:31 -0700191
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800192== Client-Server RPC
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800193
194The client-server RPC implementation is gwtjsonrpc, not the stock RPC
195system that comes with GWT. This buys us automatic XSRF protection.
196It also makes all of the messages readable and writable by any JSON
197implementation, facilitating "mashups" and 3rd party clients.
198
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800199The programming API is virtually identical, except service interfaces
200extend RemoteJsonService instead of RemoteService.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800201
202
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800203== Why GWT?
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800204
205We like it. Plus we can write Java code once and run it both in
Shawn O. Pearcee2bd1b12009-08-20 11:08:32 -0700206the browser and on the server side.
Shawn O. Pearce5500e692009-05-28 15:55:01 -0700207
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800208
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800209== External Links
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800210
211Google Web Toolkit:
212
213* http://code.google.com/webtoolkit/download.html[Download]
214
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800215Apache SSHD:
216
217* http://mina.apache.org/sshd/[SSHD]
218
219H2:
220
221* http://www.h2database.com/[H2]
222* http://www.h2database.com/html/grammar.html[SQL Reference]
223
224PostgreSQL:
225
226* http://www.postgresql.org/download/[Download]
227* http://www.postgresql.org/docs/[Documentation]
228
229
Shawn O. Pearce5500e692009-05-28 15:55:01 -0700230GERRIT
231------
232Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700233
234SEARCHBOX
235---------