Shawn O. Pearce | e31d02c | 2009-12-08 12:21:37 -0800 | [diff] [blame] | 1 | Gerrit Code Review - Developer Setup |
| 2 | ==================================== |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 3 | |
David Ostrovsky | dcee572 | 2013-05-15 00:10:55 +0200 | [diff] [blame] | 4 | Facebook Buck is needed to compile the code, and an SQL database to |
| 5 | house the review metadata. H2 is recommended for development |
| 6 | databases, as it requires no external server process. |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 7 | |
David Pursehouse | fec5879 | 2013-05-10 15:34:02 +0100 | [diff] [blame] | 8 | |
| 9 | Getting the Source |
| 10 | ------------------ |
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 | Create a new client workspace: |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 13 | |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 14 | ---- |
David Pursehouse | 4f2be53 | 2013-05-09 13:47:17 +0100 | [diff] [blame] | 15 | git clone --recursive https://gerrit.googlesource.com/gerrit |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 16 | cd gerrit |
| 17 | ---- |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 18 | |
David Pursehouse | 4f2be53 | 2013-05-09 13:47:17 +0100 | [diff] [blame] | 19 | The `--recursive` option is needed on `git clone` to ensure that |
| 20 | the core plugins, which are included as git submodules, are also |
| 21 | cloned. |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 22 | |
David Pursehouse | fec5879 | 2013-05-10 15:34:02 +0100 | [diff] [blame] | 23 | |
David Pursehouse | 6de7ee2 | 2013-05-20 11:08:51 +0900 | [diff] [blame] | 24 | Compiling |
| 25 | --------- |
| 26 | |
David Pursehouse | 5d9ef41 | 2013-05-22 13:33:45 +0900 | [diff] [blame] | 27 | For details on how to build the source code with Buck, refer to: |
| 28 | link:dev-buck.html#build[Building on the command line with Buck]. |
David Pursehouse | 6de7ee2 | 2013-05-20 11:08:51 +0900 | [diff] [blame] | 29 | |
| 30 | |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 31 | Configuring Eclipse |
| 32 | ------------------- |
| 33 | |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 34 | To use the Eclipse IDE for development, please see |
David Pursehouse | fec5879 | 2013-05-10 15:34:02 +0100 | [diff] [blame] | 35 | link:dev-eclipse.html[Eclipse Setup]. |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 36 | |
David Pursehouse | 5d9ef41 | 2013-05-22 13:33:45 +0900 | [diff] [blame] | 37 | For details on how to configure the Eclipse workspace with Buck, |
| 38 | refer to: link:dev-buck.html#eclipse[Eclipse integration with Buck]. |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 39 | |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 40 | |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 41 | Mac OS X |
David Pursehouse | fec5879 | 2013-05-10 15:34:02 +0100 | [diff] [blame] | 42 | -------- |
| 43 | |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 44 | On Mac OS X ensure "Java For Mac OS X 10.5 Upate 4" (or later) has |
| 45 | been installed, and that `JAVA_HOME` is set to |
| 46 | "/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home". |
| 47 | Check the installed version by running `java -version` and looking |
| 48 | for 'build 1.6.0_13-b03-211'. Versions of Java 6 prior to this |
| 49 | version crash during the build due to a bug in the JIT compiler. |
Shawn O. Pearce | 461c2cc | 2009-02-25 09:09:31 -0800 | [diff] [blame] | 50 | |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 51 | |
| 52 | [[init]] |
| 53 | Site Initialization |
| 54 | ------------------- |
| 55 | |
| 56 | After compiling (above), run Gerrit's 'init' command to create a |
| 57 | testing site for development use: |
| 58 | |
| 59 | ---- |
Edwin Kempin | 8baa1be | 2013-06-17 15:44:20 +0200 | [diff] [blame] | 60 | java -jar buck-out/gen/gerrit.war init -d ../test_site |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 61 | ---- |
| 62 | |
| 63 | Accept defaults by pressing Enter until 'init' completes, or add |
| 64 | the '\--batch' command line option to avoid them entirely. It is |
| 65 | recommended to change the listen addresses from '*' to 'localhost' to |
| 66 | prevent outside connections from contacting the development instance. |
| 67 | |
| 68 | The daemon will automatically start in the background and a web |
| 69 | browser will launch to the start page, enabling login via OpenID. |
| 70 | |
| 71 | Shutdown the daemon after registering the administrator account |
| 72 | through the web interface: |
| 73 | |
| 74 | ---- |
| 75 | ../test_site/bin/gerrit.sh stop |
| 76 | ---- |
| 77 | |
| 78 | |
| 79 | Testing |
| 80 | ------- |
| 81 | |
David Pursehouse | fec5879 | 2013-05-10 15:34:02 +0100 | [diff] [blame] | 82 | |
David Pursehouse | 5861a9a | 2013-05-15 10:25:19 +0900 | [diff] [blame] | 83 | [[tests]] |
Edwin Kempin | 4a3fc3f | 2013-02-27 15:18:43 +0100 | [diff] [blame] | 84 | Running the Acceptance Tests |
| 85 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 86 | |
| 87 | Gerrit has a set of integration tests that test the Gerrit daemon via |
| 88 | REST, SSH and the git protocol. |
| 89 | |
| 90 | A new review site is created for each test and the Gerrit daemon is |
| 91 | started on that site. When the test has finished the Gerrit daemon is |
| 92 | shutdown. |
| 93 | |
David Ostrovsky | dcee572 | 2013-05-15 00:10:55 +0200 | [diff] [blame] | 94 | For instructions on running the integration tests with Buck, |
David Pursehouse | 5861a9a | 2013-05-15 10:25:19 +0900 | [diff] [blame] | 95 | please refer to: |
David Pursehouse | 5d9ef41 | 2013-05-22 13:33:45 +0900 | [diff] [blame] | 96 | link:dev-buck.html#tests[Running integration tests with Buck]. |
Edwin Kempin | 4a3fc3f | 2013-02-27 15:18:43 +0100 | [diff] [blame] | 97 | |
Edwin Kempin | 4a3fc3f | 2013-02-27 15:18:43 +0100 | [diff] [blame] | 98 | |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 99 | Running the Daemon |
| 100 | ~~~~~~~~~~~~~~~~~~ |
| 101 | |
| 102 | The daemon can be directly launched from the build area, without |
| 103 | copying to the test site: |
| 104 | |
| 105 | ---- |
Edwin Kempin | 8baa1be | 2013-06-17 15:44:20 +0200 | [diff] [blame] | 106 | java -jar buck-out/gen/gerrit.war daemon -d ../test_site |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 107 | ---- |
| 108 | |
| 109 | |
| 110 | Querying the Database |
| 111 | ~~~~~~~~~~~~~~~~~~~~~ |
| 112 | |
| 113 | The embedded H2 database can be queried and updated from the |
| 114 | command line. If the daemon is not currently running: |
| 115 | |
| 116 | ---- |
Edwin Kempin | 8baa1be | 2013-06-17 15:44:20 +0200 | [diff] [blame] | 117 | java -jar buck-out/gen/gerrit.war gsql -d ../test_site |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 118 | ---- |
| 119 | |
| 120 | Or, if it is running and the database is in use, connect over SSH |
| 121 | using an administrator user account: |
| 122 | |
| 123 | ---- |
| 124 | ssh -p 29418 user@localhost gerrit gsql |
| 125 | ---- |
| 126 | |
| 127 | |
Edwin Kempin | 57fa179 | 2013-03-27 10:43:41 +0100 | [diff] [blame] | 128 | [[debug-javascript]] |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 129 | Debugging JavaScript |
| 130 | ~~~~~~~~~~~~~~~~~~~~ |
| 131 | |
Shawn Pearce | d07a622 | 2013-03-21 00:11:45 -0700 | [diff] [blame] | 132 | When debugging browser specific issues add `?dbg=1` to the URL so the |
| 133 | resulting JavaScript more closely matches the Java sources. The debug |
| 134 | pages use the GWT pretty format, where function and variable names |
| 135 | match the Java sources. |
| 136 | |
| 137 | ---- |
| 138 | http://localhost:8080/?dbg=1 |
| 139 | ---- |
| 140 | |
| 141 | To use the GWT DETAILED style the package must be recompiled and |
| 142 | `?dbg=1` must be omitted from the URL: |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 143 | |
| 144 | ---- |
Shawn O. Pearce | 4d4afa7 | 2009-12-19 18:51:33 -0800 | [diff] [blame] | 145 | mvn package -Dgwt.style=DETAILED |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 146 | ---- |
Shawn O. Pearce | 461c2cc | 2009-02-25 09:09:31 -0800 | [diff] [blame] | 147 | |
Shawn O. Pearce | 6ddb6ca | 2009-09-18 18:10:31 -0700 | [diff] [blame] | 148 | |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 149 | Release Builds |
| 150 | -------------- |
Shawn O. Pearce | 8d2f184 | 2009-05-13 07:59:04 -0700 | [diff] [blame] | 151 | |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 152 | To create a release build for a production server, or deployment |
| 153 | through the download site: |
Shawn O. Pearce | 8d2f184 | 2009-05-13 07:59:04 -0700 | [diff] [blame] | 154 | |
| 155 | ---- |
Shawn O. Pearce | d46db64 | 2009-12-18 14:47:55 -0800 | [diff] [blame] | 156 | ./tools/release.sh |
Shawn O. Pearce | 8d2f184 | 2009-05-13 07:59:04 -0700 | [diff] [blame] | 157 | ---- |
| 158 | |
Shawn O. Pearce | e6fc72f | 2010-02-22 09:31:18 -0800 | [diff] [blame] | 159 | If AsciiDoc isn't installed or is otherwise unavailable, the WAR |
| 160 | can still be built without the embedded documentation by passing |
| 161 | an additional flag: |
| 162 | |
| 163 | ---- |
| 164 | ./tools/release.sh --without-documentation |
| 165 | ---- |
| 166 | |
Shawn O. Pearce | 06b48c3 | 2009-05-10 16:21:05 -0700 | [diff] [blame] | 167 | |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 168 | Client-Server RPC |
| 169 | ----------------- |
| 170 | |
| 171 | The client-server RPC implementation is gwtjsonrpc, not the stock RPC |
| 172 | system that comes with GWT. This buys us automatic XSRF protection. |
| 173 | It also makes all of the messages readable and writable by any JSON |
| 174 | implementation, facilitating "mashups" and 3rd party clients. |
| 175 | |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 176 | The programming API is virtually identical, except service interfaces |
| 177 | extend RemoteJsonService instead of RemoteService. |
Shawn O. Pearce | d2b73db | 2009-01-09 11:55:47 -0800 | [diff] [blame] | 178 | |
| 179 | |
| 180 | Why GWT? |
| 181 | -------- |
| 182 | |
| 183 | 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] | 184 | the browser and on the server side. |
Shawn O. Pearce | 5500e69 | 2009-05-28 15:55:01 -0700 | [diff] [blame] | 185 | |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 186 | |
| 187 | External Links |
| 188 | -------------- |
| 189 | |
| 190 | Google Web Toolkit: |
| 191 | |
| 192 | * http://code.google.com/webtoolkit/download.html[Download] |
| 193 | |
Shawn O. Pearce | 18f1f7f | 2009-12-16 11:32:39 -0800 | [diff] [blame] | 194 | Apache SSHD: |
| 195 | |
| 196 | * http://mina.apache.org/sshd/[SSHD] |
| 197 | |
| 198 | H2: |
| 199 | |
| 200 | * http://www.h2database.com/[H2] |
| 201 | * http://www.h2database.com/html/grammar.html[SQL Reference] |
| 202 | |
| 203 | PostgreSQL: |
| 204 | |
| 205 | * http://www.postgresql.org/download/[Download] |
| 206 | * http://www.postgresql.org/docs/[Documentation] |
| 207 | |
| 208 | |
Shawn O. Pearce | 5500e69 | 2009-05-28 15:55:01 -0700 | [diff] [blame] | 209 | GERRIT |
| 210 | ------ |
| 211 | Part of link:index.html[Gerrit Code Review] |