blob: d961f70b216b1b5c15be0812dd5264fb2934066f [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
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080031Configuring Eclipse
32-------------------
33
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080034To use the Eclipse IDE for development, please see
David Pursehousefec58792013-05-10 15:34:02 +010035link:dev-eclipse.html[Eclipse Setup].
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080036
David Pursehouse5d9ef412013-05-22 13:33:45 +090037For details on how to configure the Eclipse workspace with Buck,
38refer to: link:dev-buck.html#eclipse[Eclipse integration with Buck].
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080039
Shawn O. Pearced2b73db2009-01-09 11:55:47 -080040
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080041Mac OS X
David Pursehousefec58792013-05-10 15:34:02 +010042--------
43
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080044On Mac OS X ensure "Java For Mac OS X 10.5 Upate 4" (or later) has
45been installed, and that `JAVA_HOME` is set to
46"/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home".
47Check the installed version by running `java -version` and looking
48for 'build 1.6.0_13-b03-211'. Versions of Java 6 prior to this
49version crash during the build due to a bug in the JIT compiler.
Shawn O. Pearce461c2cc2009-02-25 09:09:31 -080050
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080051
52[[init]]
53Site Initialization
54-------------------
55
56After compiling (above), run Gerrit's 'init' command to create a
57testing site for development use:
58
59----
Edwin Kempin8baa1be2013-06-17 15:44:20 +020060 java -jar buck-out/gen/gerrit.war init -d ../test_site
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080061----
62
63Accept defaults by pressing Enter until 'init' completes, or add
64the '\--batch' command line option to avoid them entirely. It is
65recommended to change the listen addresses from '*' to 'localhost' to
66prevent outside connections from contacting the development instance.
67
68The daemon will automatically start in the background and a web
69browser will launch to the start page, enabling login via OpenID.
70
71Shutdown the daemon after registering the administrator account
72through the web interface:
73
74----
75 ../test_site/bin/gerrit.sh stop
76----
77
78
79Testing
80-------
81
David Pursehousefec58792013-05-10 15:34:02 +010082
David Pursehouse5861a9a2013-05-15 10:25:19 +090083[[tests]]
Edwin Kempin4a3fc3f2013-02-27 15:18:43 +010084Running the Acceptance Tests
85~~~~~~~~~~~~~~~~~~~~~~~~~~~~
86
87Gerrit has a set of integration tests that test the Gerrit daemon via
88REST, SSH and the git protocol.
89
90A new review site is created for each test and the Gerrit daemon is
91started on that site. When the test has finished the Gerrit daemon is
92shutdown.
93
David Ostrovskydcee5722013-05-15 00:10:55 +020094For instructions on running the integration tests with Buck,
David Pursehouse5861a9a2013-05-15 10:25:19 +090095please refer to:
David Pursehouse5d9ef412013-05-22 13:33:45 +090096link:dev-buck.html#tests[Running integration tests with Buck].
Edwin Kempin4a3fc3f2013-02-27 15:18:43 +010097
Edwin Kempin4a3fc3f2013-02-27 15:18:43 +010098
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -080099Running the Daemon
100~~~~~~~~~~~~~~~~~~
101
102The daemon can be directly launched from the build area, without
103copying to the test site:
104
105----
Edwin Kempin8baa1be2013-06-17 15:44:20 +0200106 java -jar buck-out/gen/gerrit.war daemon -d ../test_site
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800107----
108
Marcin Cieślaked612fb2012-04-17 16:24:34 +0000109Running the Daemon with Gerrit Inspector
110~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
111
112link:dev-inspector.html[Gerrit Inspector] is an interactive scriptable
113environment to inspect and modify internal state of the system.
114
115This environment is available on the system console after
116the system starts. Leaving the Inspector will shutdown the Gerrit
117instance.
118
119The environment allows interactive work as well as running of
120Python scripts for troubleshooting.
121
122Gerrit Inspect can be started by adding '-s' option to the
123command used to launch the daemon:
124
125----
126 java -jar buck-out/gen/gerrit.war daemon -d ../test_site -s
127----
128
129Gerrit Inspector examines Java libraries first, then loads
130its initialization scripts and then starts a command line
131prompt on the console:
132
133----
134 Welcome to the Gerrit Inspector
135 Enter help() to see the above again, EOF to quit and stop Gerrit
136 Jython 2.5.2 (Release_2_5_2:7206, Mar 2 2011, 23:12:06)
137 [OpenJDK 64-Bit Server VM (Sun Microsystems Inc.)] on java1.6.0 running for Gerrit 2.3-rc0-163-g01967ef
138 >>>
139----
140
141With the Inspector enabled Gerrit can be used normally and all
142interfaces (HTTP, SSH etc.) are available.
143
144Care must be taken not to modify internal state of the system
145when using the Inspector.
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800146
147Querying the Database
148~~~~~~~~~~~~~~~~~~~~~
149
150The embedded H2 database can be queried and updated from the
151command line. If the daemon is not currently running:
152
153----
Edwin Kempin8baa1be2013-06-17 15:44:20 +0200154 java -jar buck-out/gen/gerrit.war gsql -d ../test_site
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800155----
156
157Or, if it is running and the database is in use, connect over SSH
158using an administrator user account:
159
160----
161 ssh -p 29418 user@localhost gerrit gsql
162----
163
164
Edwin Kempin57fa1792013-03-27 10:43:41 +0100165[[debug-javascript]]
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800166Debugging JavaScript
167~~~~~~~~~~~~~~~~~~~~
168
Shawn Pearced07a6222013-03-21 00:11:45 -0700169When debugging browser specific issues add `?dbg=1` to the URL so the
170resulting JavaScript more closely matches the Java sources. The debug
171pages use the GWT pretty format, where function and variable names
172match the Java sources.
173
174----
175 http://localhost:8080/?dbg=1
176----
177
178To use the GWT DETAILED style the package must be recompiled and
179`?dbg=1` must be omitted from the URL:
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800180
181----
Shawn O. Pearce4d4afa72009-12-19 18:51:33 -0800182 mvn package -Dgwt.style=DETAILED
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800183----
Shawn O. Pearce461c2cc2009-02-25 09:09:31 -0800184
Shawn O. Pearce6ddb6ca2009-09-18 18:10:31 -0700185
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800186Release Builds
187--------------
Shawn O. Pearce8d2f1842009-05-13 07:59:04 -0700188
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800189To create a release build for a production server, or deployment
190through the download site:
Shawn O. Pearce8d2f1842009-05-13 07:59:04 -0700191
192----
Shawn O. Pearced46db642009-12-18 14:47:55 -0800193 ./tools/release.sh
Shawn O. Pearce8d2f1842009-05-13 07:59:04 -0700194----
195
Shawn O. Pearcee6fc72f2010-02-22 09:31:18 -0800196If AsciiDoc isn't installed or is otherwise unavailable, the WAR
197can still be built without the embedded documentation by passing
198an additional flag:
199
200----
201 ./tools/release.sh --without-documentation
202----
203
Shawn O. Pearce06b48c32009-05-10 16:21:05 -0700204
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800205Client-Server RPC
206-----------------
207
208The client-server RPC implementation is gwtjsonrpc, not the stock RPC
209system that comes with GWT. This buys us automatic XSRF protection.
210It also makes all of the messages readable and writable by any JSON
211implementation, facilitating "mashups" and 3rd party clients.
212
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800213The programming API is virtually identical, except service interfaces
214extend RemoteJsonService instead of RemoteService.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800215
216
217Why GWT?
218--------
219
220We like it. Plus we can write Java code once and run it both in
Shawn O. Pearcee2bd1b12009-08-20 11:08:32 -0700221the browser and on the server side.
Shawn O. Pearce5500e692009-05-28 15:55:01 -0700222
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800223
224External Links
225--------------
226
227Google Web Toolkit:
228
229* http://code.google.com/webtoolkit/download.html[Download]
230
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800231Apache SSHD:
232
233* http://mina.apache.org/sshd/[SSHD]
234
235H2:
236
237* http://www.h2database.com/[H2]
238* http://www.h2database.com/html/grammar.html[SQL Reference]
239
240PostgreSQL:
241
242* http://www.postgresql.org/download/[Download]
243* http://www.postgresql.org/docs/[Documentation]
244
245
Shawn O. Pearce5500e692009-05-28 15:55:01 -0700246GERRIT
247------
248Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700249
250SEARCHBOX
251---------