blob: ced8648f65dee56e4ec42147ff012fb0dc399853 [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
109
110Querying the Database
111~~~~~~~~~~~~~~~~~~~~~
112
113The embedded H2 database can be queried and updated from the
114command line. If the daemon is not currently running:
115
116----
Edwin Kempin8baa1be2013-06-17 15:44:20 +0200117 java -jar buck-out/gen/gerrit.war gsql -d ../test_site
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800118----
119
120Or, if it is running and the database is in use, connect over SSH
121using an administrator user account:
122
123----
124 ssh -p 29418 user@localhost gerrit gsql
125----
126
127
Edwin Kempin57fa1792013-03-27 10:43:41 +0100128[[debug-javascript]]
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800129Debugging JavaScript
130~~~~~~~~~~~~~~~~~~~~
131
Shawn Pearced07a6222013-03-21 00:11:45 -0700132When debugging browser specific issues add `?dbg=1` to the URL so the
133resulting JavaScript more closely matches the Java sources. The debug
134pages use the GWT pretty format, where function and variable names
135match the Java sources.
136
137----
138 http://localhost:8080/?dbg=1
139----
140
141To use the GWT DETAILED style the package must be recompiled and
142`?dbg=1` must be omitted from the URL:
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800143
144----
Shawn O. Pearce4d4afa72009-12-19 18:51:33 -0800145 mvn package -Dgwt.style=DETAILED
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800146----
Shawn O. Pearce461c2cc2009-02-25 09:09:31 -0800147
Shawn O. Pearce6ddb6ca2009-09-18 18:10:31 -0700148
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800149Release Builds
150--------------
Shawn O. Pearce8d2f1842009-05-13 07:59:04 -0700151
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800152To create a release build for a production server, or deployment
153through the download site:
Shawn O. Pearce8d2f1842009-05-13 07:59:04 -0700154
155----
Shawn O. Pearced46db642009-12-18 14:47:55 -0800156 ./tools/release.sh
Shawn O. Pearce8d2f1842009-05-13 07:59:04 -0700157----
158
Shawn O. Pearcee6fc72f2010-02-22 09:31:18 -0800159If AsciiDoc isn't installed or is otherwise unavailable, the WAR
160can still be built without the embedded documentation by passing
161an additional flag:
162
163----
164 ./tools/release.sh --without-documentation
165----
166
Shawn O. Pearce06b48c32009-05-10 16:21:05 -0700167
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800168Client-Server RPC
169-----------------
170
171The client-server RPC implementation is gwtjsonrpc, not the stock RPC
172system that comes with GWT. This buys us automatic XSRF protection.
173It also makes all of the messages readable and writable by any JSON
174implementation, facilitating "mashups" and 3rd party clients.
175
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800176The programming API is virtually identical, except service interfaces
177extend RemoteJsonService instead of RemoteService.
Shawn O. Pearced2b73db2009-01-09 11:55:47 -0800178
179
180Why GWT?
181--------
182
183We like it. Plus we can write Java code once and run it both in
Shawn O. Pearcee2bd1b12009-08-20 11:08:32 -0700184the browser and on the server side.
Shawn O. Pearce5500e692009-05-28 15:55:01 -0700185
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800186
187External Links
188--------------
189
190Google Web Toolkit:
191
192* http://code.google.com/webtoolkit/download.html[Download]
193
Shawn O. Pearce18f1f7f2009-12-16 11:32:39 -0800194Apache SSHD:
195
196* http://mina.apache.org/sshd/[SSHD]
197
198H2:
199
200* http://www.h2database.com/[H2]
201* http://www.h2database.com/html/grammar.html[SQL Reference]
202
203PostgreSQL:
204
205* http://www.postgresql.org/download/[Download]
206* http://www.postgresql.org/docs/[Documentation]
207
208
Shawn O. Pearce5500e692009-05-28 15:55:01 -0700209GERRIT
210------
211Part of link:index.html[Gerrit Code Review]