Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 1 | = Gerrit Code Review - Developer Setup |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 2 | |
David Ostrovsky | dcee572 | 2013-05-15 00:10:55 +0200 | [diff] [blame] | 3 | Facebook Buck is needed to compile the code, and an SQL database to |
| 4 | house the review metadata. H2 is recommended for development |
| 5 | databases, as it requires no external server process. |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 6 | |
David Pursehouse | fec5879 | 2013-05-10 15:34:02 +0100 | [diff] [blame] | 7 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 8 | == Getting the Source |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 9 | |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 10 | Create a new client workspace: |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 11 | |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 12 | ---- |
David Pursehouse | 4f2be53 | 2013-05-09 13:47:17 +0100 | [diff] [blame] | 13 | git clone --recursive https://gerrit.googlesource.com/gerrit |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 14 | cd gerrit |
| 15 | ---- |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 16 | |
David Pursehouse | 4f2be53 | 2013-05-09 13:47:17 +0100 | [diff] [blame] | 17 | The `--recursive` option is needed on `git clone` to ensure that |
| 18 | the core plugins, which are included as git submodules, are also |
| 19 | cloned. |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 20 | |
David Pursehouse | fec5879 | 2013-05-10 15:34:02 +0100 | [diff] [blame] | 21 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 22 | == Compiling |
David Pursehouse | 6de7ee2 | 2013-05-20 11:08:51 +0900 | [diff] [blame] | 23 | |
David Pursehouse | 5d9ef41 | 2013-05-22 13:33:45 +0900 | [diff] [blame] | 24 | For details on how to build the source code with Buck, refer to: |
| 25 | link:dev-buck.html#build[Building on the command line with Buck]. |
David Pursehouse | 6de7ee2 | 2013-05-20 11:08:51 +0900 | [diff] [blame] | 26 | |
| 27 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 28 | == Switching between branches |
David Pursehouse | d106c8e | 2013-12-13 15:03:02 +0900 | [diff] [blame] | 29 | |
| 30 | When switching between branches with `git checkout`, be aware that |
| 31 | submodule revisions are not altered. This may result in the wrong |
| 32 | plugin revisions being present, unneeded plugins being present, or |
| 33 | expected plugins being missing. |
| 34 | |
| 35 | After switching branches, make sure the submodules are at the correct |
| 36 | revisions for the new branch with the commands: |
| 37 | |
| 38 | ---- |
| 39 | git submodule update |
| 40 | git clean -fdx |
| 41 | ---- |
| 42 | |
| 43 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 44 | == Configuring Eclipse |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 45 | |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 46 | To use the Eclipse IDE for development, please see |
David Pursehouse | fec5879 | 2013-05-10 15:34:02 +0100 | [diff] [blame] | 47 | link:dev-eclipse.html[Eclipse Setup]. |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 48 | |
David Pursehouse | 5d9ef41 | 2013-05-22 13:33:45 +0900 | [diff] [blame] | 49 | For details on how to configure the Eclipse workspace with Buck, |
| 50 | refer to: link:dev-buck.html#eclipse[Eclipse integration with Buck]. |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 51 | |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 52 | |
Urs Wolfer | c0948bd | 2014-04-27 21:16:25 +0200 | [diff] [blame] | 53 | == Configuring IntelliJ IDEA |
| 54 | |
| 55 | To use IntelliJ IDEA for development, the easiest way is to follow |
| 56 | Eclipse integration and then open it as Eclipse project in IDEA. |
| 57 | You need the Eclipse plugin activated in IntelliJ IDEA. |
| 58 | |
| 59 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 60 | == Mac OS X |
David Pursehouse | fec5879 | 2013-05-10 15:34:02 +0100 | [diff] [blame] | 61 | |
Khai Do | ea9e4b7 | 2014-03-30 07:43:31 -0700 | [diff] [blame] | 62 | On Mac OS X ensure "Java For Mac OS X 10.5 Update 4" (or later) has |
| 63 | been installed, and that `JAVA_HOME` is set to the |
| 64 | link:install.html#Requirements[required Java version]. |
Shawn O. Pearce | 461c2cc | 2009-02-25 09:09:31 -0800 | [diff] [blame] | 65 | |
Khai Do | ea9e4b7 | 2014-03-30 07:43:31 -0700 | [diff] [blame] | 66 | Java installations can typically be found in |
| 67 | "/System/Library/Frameworks/JavaVM.framework/Versions". |
| 68 | |
| 69 | You can check the installed Java version by running `java -version` in |
| 70 | the terminal. |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 71 | |
| 72 | [[init]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 73 | == Site Initialization |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 74 | |
| 75 | After compiling (above), run Gerrit's 'init' command to create a |
| 76 | testing site for development use: |
| 77 | |
| 78 | ---- |
David Pursehouse | 9db2378 | 2013-12-17 11:59:22 +0900 | [diff] [blame] | 79 | java -jar buck-out/gen/gerrit.war init -d ../gerrit_testsite |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 80 | ---- |
| 81 | |
| 82 | Accept defaults by pressing Enter until 'init' completes, or add |
Yuxuan 'fishy' Wang | 77e1508 | 2013-12-09 15:43:25 -0800 | [diff] [blame] | 83 | the '--batch' command line option to avoid them entirely. It is |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 84 | recommended to change the listen addresses from '*' to 'localhost' to |
| 85 | prevent outside connections from contacting the development instance. |
| 86 | |
| 87 | The daemon will automatically start in the background and a web |
| 88 | browser will launch to the start page, enabling login via OpenID. |
| 89 | |
| 90 | Shutdown the daemon after registering the administrator account |
| 91 | through the web interface: |
| 92 | |
| 93 | ---- |
David Pursehouse | 9db2378 | 2013-12-17 11:59:22 +0900 | [diff] [blame] | 94 | ../gerrit_testsite/bin/gerrit.sh stop |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 95 | ---- |
| 96 | |
| 97 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 98 | == Testing |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 99 | |
David Pursehouse | fec5879 | 2013-05-10 15:34:02 +0100 | [diff] [blame] | 100 | |
David Pursehouse | 5861a9a | 2013-05-15 10:25:19 +0900 | [diff] [blame] | 101 | [[tests]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 102 | === Running the Acceptance Tests |
Edwin Kempin | 4a3fc3f | 2013-02-27 15:18:43 +0100 | [diff] [blame] | 103 | |
| 104 | Gerrit has a set of integration tests that test the Gerrit daemon via |
| 105 | REST, SSH and the git protocol. |
| 106 | |
| 107 | A new review site is created for each test and the Gerrit daemon is |
| 108 | started on that site. When the test has finished the Gerrit daemon is |
| 109 | shutdown. |
| 110 | |
David Ostrovsky | dcee572 | 2013-05-15 00:10:55 +0200 | [diff] [blame] | 111 | For instructions on running the integration tests with Buck, |
David Pursehouse | 5861a9a | 2013-05-15 10:25:19 +0900 | [diff] [blame] | 112 | please refer to: |
David Pursehouse | 5d9ef41 | 2013-05-22 13:33:45 +0900 | [diff] [blame] | 113 | link:dev-buck.html#tests[Running integration tests with Buck]. |
Edwin Kempin | 4a3fc3f | 2013-02-27 15:18:43 +0100 | [diff] [blame] | 114 | |
Edwin Kempin | 4a3fc3f | 2013-02-27 15:18:43 +0100 | [diff] [blame] | 115 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 116 | === Running the Daemon |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 117 | |
| 118 | The daemon can be directly launched from the build area, without |
| 119 | copying to the test site: |
| 120 | |
| 121 | ---- |
David Pursehouse | 9db2378 | 2013-12-17 11:59:22 +0900 | [diff] [blame] | 122 | java -jar buck-out/gen/gerrit.war daemon -d ../gerrit_testsite |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 123 | ---- |
| 124 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 125 | === Running the Daemon with Gerrit Inspector |
Marcin Cieślak | ed612fb | 2012-04-17 16:24:34 +0000 | [diff] [blame] | 126 | |
| 127 | link:dev-inspector.html[Gerrit Inspector] is an interactive scriptable |
| 128 | environment to inspect and modify internal state of the system. |
| 129 | |
| 130 | This environment is available on the system console after |
| 131 | the system starts. Leaving the Inspector will shutdown the Gerrit |
| 132 | instance. |
| 133 | |
| 134 | The environment allows interactive work as well as running of |
| 135 | Python scripts for troubleshooting. |
| 136 | |
| 137 | Gerrit Inspect can be started by adding '-s' option to the |
| 138 | command used to launch the daemon: |
| 139 | |
| 140 | ---- |
David Pursehouse | 9db2378 | 2013-12-17 11:59:22 +0900 | [diff] [blame] | 141 | java -jar buck-out/gen/gerrit.war daemon -d ../gerrit_testsite -s |
Marcin Cieślak | ed612fb | 2012-04-17 16:24:34 +0000 | [diff] [blame] | 142 | ---- |
| 143 | |
| 144 | Gerrit Inspector examines Java libraries first, then loads |
| 145 | its initialization scripts and then starts a command line |
| 146 | prompt 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 | |
| 156 | With the Inspector enabled Gerrit can be used normally and all |
| 157 | interfaces (HTTP, SSH etc.) are available. |
| 158 | |
| 159 | Care must be taken not to modify internal state of the system |
| 160 | when using the Inspector. |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 161 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 162 | === Querying the Database |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 163 | |
| 164 | The embedded H2 database can be queried and updated from the |
| 165 | command line. If the daemon is not currently running: |
| 166 | |
| 167 | ---- |
David Pursehouse | 9db2378 | 2013-12-17 11:59:22 +0900 | [diff] [blame] | 168 | java -jar buck-out/gen/gerrit.war gsql -d ../gerrit_testsite |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 169 | ---- |
| 170 | |
| 171 | Or, if it is running and the database is in use, connect over SSH |
| 172 | using an administrator user account: |
| 173 | |
| 174 | ---- |
| 175 | ssh -p 29418 user@localhost gerrit gsql |
| 176 | ---- |
| 177 | |
| 178 | |
Edwin Kempin | 57fa179 | 2013-03-27 10:43:41 +0100 | [diff] [blame] | 179 | [[debug-javascript]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 180 | === Debugging JavaScript |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 181 | |
Shawn Pearce | d07a622 | 2013-03-21 00:11:45 -0700 | [diff] [blame] | 182 | When debugging browser specific issues add `?dbg=1` to the URL so the |
| 183 | resulting JavaScript more closely matches the Java sources. The debug |
| 184 | pages use the GWT pretty format, where function and variable names |
| 185 | match the Java sources. |
| 186 | |
| 187 | ---- |
| 188 | http://localhost:8080/?dbg=1 |
| 189 | ---- |
| 190 | |
Shawn O. Pearce | 6ddb6ca | 2009-09-18 18:10:31 -0700 | [diff] [blame] | 191 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 192 | == Client-Server RPC |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 193 | |
| 194 | The client-server RPC implementation is gwtjsonrpc, not the stock RPC |
| 195 | system that comes with GWT. This buys us automatic XSRF protection. |
| 196 | It also makes all of the messages readable and writable by any JSON |
| 197 | implementation, facilitating "mashups" and 3rd party clients. |
| 198 | |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 199 | The programming API is virtually identical, except service interfaces |
| 200 | extend RemoteJsonService instead of RemoteService. |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 201 | |
| 202 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 203 | == Why GWT? |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 204 | |
| 205 | We like it. Plus we can write Java code once and run it both in |
Shawn O. Pearce | e2bd1b1 | 2009-08-20 11:08:32 -0700 | [diff] [blame] | 206 | the browser and on the server side. |
Shawn O. Pearce | 5500e69 | 2009-05-28 15:55:01 -0700 | [diff] [blame] | 207 | |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 208 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 209 | == External Links |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 210 | |
| 211 | Google Web Toolkit: |
| 212 | |
| 213 | * http://code.google.com/webtoolkit/download.html[Download] |
| 214 | |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 215 | Apache SSHD: |
| 216 | |
| 217 | * http://mina.apache.org/sshd/[SSHD] |
| 218 | |
| 219 | H2: |
| 220 | |
| 221 | * http://www.h2database.com/[H2] |
| 222 | * http://www.h2database.com/html/grammar.html[SQL Reference] |
| 223 | |
| 224 | PostgreSQL: |
| 225 | |
| 226 | * http://www.postgresql.org/download/[Download] |
| 227 | * http://www.postgresql.org/docs/[Documentation] |
| 228 | |
| 229 | |
Shawn O. Pearce | 5500e69 | 2009-05-28 15:55:01 -0700 | [diff] [blame] | 230 | GERRIT |
| 231 | ------ |
| 232 | Part of link:index.html[Gerrit Code Review] |
Yuxuan 'fishy' Wang | 99cb68d | 2013-10-31 17:26:00 -0700 | [diff] [blame] | 233 | |
| 234 | SEARCHBOX |
| 235 | --------- |