blob: 10455c05cfd881b703f2af35939d99e16d9e0555 [file] [log] [blame]
Shawn O. Pearcee31d02c2009-12-08 12:21:37 -08001Gerrit Code Review - Developer Setup
2====================================
Shawn O. Pearced2b73db2009-01-09 11:55:47 -08003
David Ostrovskydcee5722013-05-15 00:10:55 +02004Facebook Buck is needed to compile the code, and an SQL database to
5house the review metadata. H2 is recommended for development
6databases, as it requires no external server process.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -08007
David Pursehousefec58792013-05-10 15:34:02 +01008
9Getting the Source
10------------------
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080011
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080012Create a new client workspace:
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080013
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080014----
David Pursehouse4f2be532013-05-09 13:47:17 +010015 git clone --recursive https://gerrit.googlesource.com/gerrit
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080016 cd gerrit
17----
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080018
David Pursehouse4f2be532013-05-09 13:47:17 +010019The `--recursive` option is needed on `git clone` to ensure that
20the core plugins, which are included as git submodules, are also
21cloned.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080022
David Pursehousefec58792013-05-10 15:34:02 +010023
David Pursehouse6de7ee22013-05-20 11:08:51 +090024Compiling
25---------
26
David Pursehouse5d9ef412013-05-22 13:33:45 +090027For details on how to build the source code with Buck, refer to:
28link:dev-buck.html#build[Building on the command line with Buck].
David Pursehouse6de7ee22013-05-20 11:08:51 +090029
30
David Pursehoused106c8e2013-12-13 15:03:02 +090031Switching between branches
32--------------------------
33
34When switching between branches with `git checkout`, be aware that
35submodule revisions are not altered. This may result in the wrong
36plugin revisions being present, unneeded plugins being present, or
37expected plugins being missing.
38
39After switching branches, make sure the submodules are at the correct
40revisions for the new branch with the commands:
41
42----
43 git submodule update
44 git clean -fdx
45----
46
47
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080048Configuring Eclipse
49-------------------
50
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080051To use the Eclipse IDE for development, please see
David Pursehousefec58792013-05-10 15:34:02 +010052link:dev-eclipse.html[Eclipse Setup].
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080053
David Pursehouse5d9ef412013-05-22 13:33:45 +090054For details on how to configure the Eclipse workspace with Buck,
55refer to: link:dev-buck.html#eclipse[Eclipse integration with Buck].
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080056
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080057
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080058Mac OS X
David Pursehousefec58792013-05-10 15:34:02 +010059--------
60
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080061On Mac OS X ensure "Java For Mac OS X 10.5 Upate 4" (or later) has
62been installed, and that `JAVA_HOME` is set to
63"/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home".
64Check the installed version by running `java -version` and looking
65for 'build 1.6.0_13-b03-211'. Versions of Java 6 prior to this
66version crash during the build due to a bug in the JIT compiler.
Shawn O. Pearce461c2cc2009-02-25 09:09:31 -080067
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080068
69[[init]]
70Site Initialization
71-------------------
72
73After compiling (above), run Gerrit's 'init' command to create a
74testing site for development use:
75
76----
Edwin Kempin8baa1be2013-06-17 15:44:20 +020077 java -jar buck-out/gen/gerrit.war init -d ../test_site
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080078----
79
80Accept defaults by pressing Enter until 'init' completes, or add
Yuxuan 'fishy' Wang77e15082013-12-09 15:43:25 -080081the '--batch' command line option to avoid them entirely. It is
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080082recommended to change the listen addresses from '*' to 'localhost' to
83prevent outside connections from contacting the development instance.
84
85The daemon will automatically start in the background and a web
86browser will launch to the start page, enabling login via OpenID.
87
88Shutdown the daemon after registering the administrator account
89through the web interface:
90
91----
92 ../test_site/bin/gerrit.sh stop
93----
94
95
96Testing
97-------
98
David Pursehousefec58792013-05-10 15:34:02 +010099
David Pursehouse5861a9a2013-05-15 10:25:19 +0900100[[tests]]
Edwin Kempin4a3fc3f2013-02-27 15:18:43 +0100101Running the Acceptance Tests
102~~~~~~~~~~~~~~~~~~~~~~~~~~~~
103
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
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800116Running the Daemon
117~~~~~~~~~~~~~~~~~~
118
119The daemon can be directly launched from the build area, without
120copying to the test site:
121
122----
Edwin Kempin8baa1be2013-06-17 15:44:20 +0200123 java -jar buck-out/gen/gerrit.war daemon -d ../test_site
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800124----
125
Marcin Cieślaked612fb2012-04-17 16:24:34 +0000126Running the Daemon with Gerrit Inspector
127~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
128
129link:dev-inspector.html[Gerrit Inspector] is an interactive scriptable
130environment to inspect and modify internal state of the system.
131
132This environment is available on the system console after
133the system starts. Leaving the Inspector will shutdown the Gerrit
134instance.
135
136The environment allows interactive work as well as running of
137Python scripts for troubleshooting.
138
139Gerrit Inspect can be started by adding '-s' option to the
140command used to launch the daemon:
141
142----
143 java -jar buck-out/gen/gerrit.war daemon -d ../test_site -s
144----
145
146Gerrit Inspector examines Java libraries first, then loads
147its initialization scripts and then starts a command line
148prompt on the console:
149
150----
151 Welcome to the Gerrit Inspector
152 Enter help() to see the above again, EOF to quit and stop Gerrit
153 Jython 2.5.2 (Release_2_5_2:7206, Mar 2 2011, 23:12:06)
154 [OpenJDK 64-Bit Server VM (Sun Microsystems Inc.)] on java1.6.0 running for Gerrit 2.3-rc0-163-g01967ef
155 >>>
156----
157
158With the Inspector enabled Gerrit can be used normally and all
159interfaces (HTTP, SSH etc.) are available.
160
161Care must be taken not to modify internal state of the system
162when using the Inspector.
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800163
164Querying the Database
165~~~~~~~~~~~~~~~~~~~~~
166
167The embedded H2 database can be queried and updated from the
168command line. If the daemon is not currently running:
169
170----
Edwin Kempin8baa1be2013-06-17 15:44:20 +0200171 java -jar buck-out/gen/gerrit.war gsql -d ../test_site
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800172----
173
174Or, if it is running and the database is in use, connect over SSH
175using an administrator user account:
176
177----
178 ssh -p 29418 user@localhost gerrit gsql
179----
180
181
Edwin Kempin57fa1792013-03-27 10:43:41 +0100182[[debug-javascript]]
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800183Debugging JavaScript
184~~~~~~~~~~~~~~~~~~~~
185
Shawn Pearced07a6222013-03-21 00:11:45 -0700186When debugging browser specific issues add `?dbg=1` to the URL so the
187resulting JavaScript more closely matches the Java sources. The debug
188pages use the GWT pretty format, where function and variable names
189match the Java sources.
190
191----
192 http://localhost:8080/?dbg=1
193----
194
195To use the GWT DETAILED style the package must be recompiled and
196`?dbg=1` must be omitted from the URL:
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800197
198----
Shawn O. Pearce4d4afa72009-12-19 18:51:33 -0800199 mvn package -Dgwt.style=DETAILED
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800200----
Shawn O. Pearce461c2cc2009-02-25 09:09:31 -0800201
Shawn O. Pearce6ddb6ca2009-09-18 18:10:31 -0700202
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800203Release Builds
204--------------
Shawn O. Pearce8d2f1842009-05-13 07:59:04 -0700205
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800206To create a release build for a production server, or deployment
207through the download site:
Shawn O. Pearce8d2f1842009-05-13 07:59:04 -0700208
209----
Shawn O. Pearced46db642009-12-18 14:47:55 -0800210 ./tools/release.sh
Shawn O. Pearce8d2f1842009-05-13 07:59:04 -0700211----
212
Shawn O. Pearcee6fc72f2010-02-22 09:31:18 -0800213If AsciiDoc isn't installed or is otherwise unavailable, the WAR
214can still be built without the embedded documentation by passing
215an additional flag:
216
217----
218 ./tools/release.sh --without-documentation
219----
220
Shawn O. Pearce06b48c32009-05-10 16:21:05 -0700221
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800222Client-Server RPC
223-----------------
224
225The client-server RPC implementation is gwtjsonrpc, not the stock RPC
226system that comes with GWT. This buys us automatic XSRF protection.
227It also makes all of the messages readable and writable by any JSON
228implementation, facilitating "mashups" and 3rd party clients.
229
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800230The programming API is virtually identical, except service interfaces
231extend RemoteJsonService instead of RemoteService.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800232
233
234Why GWT?
235--------
236
237We like it. Plus we can write Java code once and run it both in
Shawn O. Pearcee2bd1b12009-08-20 11:08:32 -0700238the browser and on the server side.
Shawn O. Pearce5500e692009-05-28 15:55:01 -0700239
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800240
241External Links
242--------------
243
244Google Web Toolkit:
245
246* http://code.google.com/webtoolkit/download.html[Download]
247
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800248Apache SSHD:
249
250* http://mina.apache.org/sshd/[SSHD]
251
252H2:
253
254* http://www.h2database.com/[H2]
255* http://www.h2database.com/html/grammar.html[SQL Reference]
256
257PostgreSQL:
258
259* http://www.postgresql.org/download/[Download]
260* http://www.postgresql.org/docs/[Documentation]
261
262
Shawn O. Pearce5500e692009-05-28 15:55:01 -0700263GERRIT
264------
265Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700266
267SEARCHBOX
268---------