David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 1 | Gerrit Code Review - Building with Buck |
| 2 | ======================================= |
| 3 | |
| 4 | |
| 5 | Installation |
| 6 | ------------ |
| 7 | |
| 8 | There is currently no binary distribution of Buck, so it has to be manually |
David Pursehouse | 64c1644 | 2013-05-14 10:49:03 +0900 | [diff] [blame] | 9 | built and installed. Apache Ant is required. Currently only Linux and Mac |
| 10 | OS are supported. |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 11 | |
| 12 | Clone the git and build it: |
| 13 | |
| 14 | ---- |
| 15 | git clone https://gerrit.googlesource.com/buck |
| 16 | cd buck |
| 17 | ant |
| 18 | ---- |
| 19 | |
David Pursehouse | 5c42b8c | 2013-05-17 13:25:47 +0100 | [diff] [blame] | 20 | Make sure you have a `bin/` directory in your home directory and that |
| 21 | it is included in your path: |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 22 | |
| 23 | ---- |
David Pursehouse | 64c1644 | 2013-05-14 10:49:03 +0900 | [diff] [blame] | 24 | mkdir ~/bin |
| 25 | PATH=~/bin:$PATH |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 26 | ---- |
| 27 | |
David Pursehouse | 5c42b8c | 2013-05-17 13:25:47 +0100 | [diff] [blame] | 28 | Add a symbolic link in `~/bin` to the buck executable: |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 29 | |
| 30 | ---- |
David Pursehouse | 64c1644 | 2013-05-14 10:49:03 +0900 | [diff] [blame] | 31 | ln -s `pwd`/bin/buck ~/bin/ |
| 32 | ---- |
| 33 | |
David Pursehouse | 5c42b8c | 2013-05-17 13:25:47 +0100 | [diff] [blame] | 34 | Verify that `buck` is accessible: |
David Pursehouse | 64c1644 | 2013-05-14 10:49:03 +0900 | [diff] [blame] | 35 | |
| 36 | ---- |
| 37 | which buck |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 38 | ---- |
| 39 | |
Edwin Kempin | 9a8b1dc | 2013-09-16 09:08:34 +0200 | [diff] [blame] | 40 | If you plan to use the link:#buck-daemon[Buck daemon] add a symbolic |
| 41 | link in `~/bin` to the buckd executable: |
| 42 | |
| 43 | ---- |
| 44 | ln -s `pwd`/bin/buckd ~/bin/ |
| 45 | ---- |
| 46 | |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 47 | |
David Pursehouse | 5861a9a | 2013-05-15 10:25:19 +0900 | [diff] [blame] | 48 | [[eclipse]] |
| 49 | Eclipse Integration |
| 50 | ------------------- |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 51 | |
| 52 | |
| 53 | Generating the Eclipse Project |
| 54 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 55 | |
Shawn Pearce | a7a3ee1 | 2013-09-20 10:42:37 -0700 | [diff] [blame] | 56 | Create the Eclipse project: |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 57 | |
| 58 | ---- |
Shawn Pearce | a7a3ee1 | 2013-09-20 10:42:37 -0700 | [diff] [blame] | 59 | tools/eclipse/project.py |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 60 | ---- |
| 61 | |
| 62 | In Eclipse, choose 'Import existing project' and select the `gerrit` project |
Edwin Kempin | 0d687ff | 2013-06-14 09:41:07 +0200 | [diff] [blame] | 63 | from the current working directory. |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 64 | |
| 65 | Expand the `gerrit` project, right-click on the `buck-out` folder, select |
| 66 | 'Properties', and then under 'Attributes' check 'Derived'. |
| 67 | |
Shawn Pearce | a7a3ee1 | 2013-09-20 10:42:37 -0700 | [diff] [blame] | 68 | Note that if you make any changes in the project configuration |
| 69 | that get saved to the `.project` file, for example adding Resource |
| 70 | Filters on a folder, they will be overwritten the next time you run |
| 71 | `tools/eclipse/project.py`. |
David Pursehouse | 38ba880 | 2013-05-17 13:42:03 +0100 | [diff] [blame] | 72 | |
David Pursehouse | b46cf49 | 2013-05-14 09:41:30 +0900 | [diff] [blame] | 73 | |
David Pursehouse | 1d0435e | 2013-05-14 10:26:51 +0900 | [diff] [blame] | 74 | Refreshing the Classpath |
| 75 | ~~~~~~~~~~~~~~~~~~~~~~~~ |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 76 | |
Shawn Pearce | a7a3ee1 | 2013-09-20 10:42:37 -0700 | [diff] [blame] | 77 | If an updated classpath is needed, the Eclipse project can be |
| 78 | refreshed and missing dependency JARs can be downloaded: |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 79 | |
| 80 | ---- |
Shawn Pearce | a7a3ee1 | 2013-09-20 10:42:37 -0700 | [diff] [blame] | 81 | tools/eclipse/project.py |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 82 | ---- |
| 83 | |
| 84 | |
Shawn Pearce | 7b55326 | 2013-05-13 21:25:13 -0700 | [diff] [blame] | 85 | Attaching Sources |
| 86 | ~~~~~~~~~~~~~~~~~ |
| 87 | |
| 88 | To save time and bandwidth source JARs are only downloaded by the buck |
| 89 | build where necessary to compile Java source into JavaScript using the |
| 90 | GWT compiler. Additional sources may be obtained, allowing Eclipse to |
| 91 | show documentation or dive into the implementation of a library JAR: |
| 92 | |
| 93 | ---- |
Shawn Pearce | a7a3ee1 | 2013-09-20 10:42:37 -0700 | [diff] [blame] | 94 | tools/eclipse/project.py --src |
Shawn Pearce | 7b55326 | 2013-05-13 21:25:13 -0700 | [diff] [blame] | 95 | ---- |
| 96 | |
| 97 | |
David Pursehouse | 6de7ee2 | 2013-05-20 11:08:51 +0900 | [diff] [blame] | 98 | [[build]] |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 99 | Building on the Command Line |
| 100 | ---------------------------- |
| 101 | |
| 102 | |
| 103 | Gerrit Development WAR File |
| 104 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 105 | |
| 106 | To build the Gerrit web application: |
| 107 | |
| 108 | ---- |
| 109 | buck build gerrit |
| 110 | ---- |
| 111 | |
| 112 | The output executable WAR will be placed in: |
| 113 | |
| 114 | ---- |
| 115 | buck-out/gen/gerrit.war |
| 116 | ---- |
| 117 | |
| 118 | |
| 119 | Extension and Plugin API JAR Files |
| 120 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 121 | |
| 122 | To build the extension and plugin API JAR files: |
| 123 | |
| 124 | ---- |
| 125 | buck build api |
| 126 | ---- |
| 127 | |
| 128 | The output JAR files will be placed in: |
| 129 | |
| 130 | ---- |
| 131 | buck-out/gen/{extension,plugin}-api.jar |
| 132 | ---- |
| 133 | |
David Ostrovsky | 6e6a967 | 2013-05-30 01:10:12 +0200 | [diff] [blame] | 134 | Install {extension,plugin}-api to the local maven repository: |
| 135 | |
| 136 | ---- |
| 137 | buck build api_install |
| 138 | ---- |
| 139 | |
| 140 | Deploy {extension,plugin}-api to the remote maven repository |
| 141 | |
| 142 | ---- |
| 143 | buck build api_deploy |
| 144 | ---- |
| 145 | |
| 146 | The type of the repo is induced from the Gerrit version name, i.e. |
| 147 | * 2.8-SNAPSHOT: shapshot repo |
| 148 | * 2.8: release repo |
David Pursehouse | b46cf49 | 2013-05-14 09:41:30 +0900 | [diff] [blame] | 149 | |
David Pursehouse | 0bc51db | 2013-05-14 12:46:49 +0900 | [diff] [blame] | 150 | Plugins |
| 151 | ~~~~~~~ |
| 152 | |
| 153 | To build all core plugins: |
| 154 | |
| 155 | ---- |
| 156 | buck build plugins:core |
| 157 | ---- |
| 158 | |
| 159 | The output JAR files for individual plugins will be placed in: |
| 160 | |
| 161 | ---- |
| 162 | buck-out/gen/plugins/<name>/<name>.jar |
| 163 | ---- |
| 164 | |
| 165 | The JAR files will also be packaged in: |
| 166 | |
| 167 | ---- |
| 168 | buck-out/gen/plugins/core.zip |
| 169 | ---- |
| 170 | |
| 171 | To build a specific plugin: |
| 172 | |
| 173 | ---- |
| 174 | buck build plugins/<name> |
| 175 | ---- |
| 176 | |
| 177 | The output JAR file will be be placed in: |
| 178 | |
| 179 | ---- |
| 180 | buck-out/gen/plugins/<name>/<name>.jar |
| 181 | ---- |
| 182 | |
| 183 | Note that when building an individual plugin, the `core.zip` package |
| 184 | is not regenerated. |
| 185 | |
David Pursehouse | 90a9c10 | 2013-09-06 18:42:10 +0900 | [diff] [blame] | 186 | |
| 187 | [[documentation]] |
| 188 | Documentation |
| 189 | ~~~~~~~~~~~~~ |
| 190 | |
| 191 | To build the documentation: |
| 192 | |
| 193 | ---- |
| 194 | buck build docs |
| 195 | ---- |
| 196 | |
| 197 | The generated html files will be placed in: |
| 198 | |
| 199 | ---- |
| 200 | buck-out/gen/Documentation |
| 201 | ---- |
| 202 | |
| 203 | The html files will also be bundled into `html.zip` in the same location. |
| 204 | |
| 205 | |
David Ostrovsky | 811e603 | 2013-09-06 08:35:45 +0200 | [diff] [blame] | 206 | [[release]] |
| 207 | Gerrit Release WAR File |
| 208 | ~~~~~~~~~~~~~~~~~~~~~~~ |
| 209 | |
| 210 | To build the release of the Gerrit web application, including documentation and |
| 211 | all core plugins: |
| 212 | |
| 213 | ---- |
| 214 | buck build release |
| 215 | ---- |
| 216 | |
| 217 | The output release WAR will be placed in: |
| 218 | |
| 219 | ---- |
| 220 | buck-out/gen/release.war |
| 221 | ---- |
David Pursehouse | 0bc51db | 2013-05-14 12:46:49 +0900 | [diff] [blame] | 222 | |
David Pursehouse | 5861a9a | 2013-05-15 10:25:19 +0900 | [diff] [blame] | 223 | [[tests]] |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 224 | Running Unit Tests |
| 225 | ------------------ |
| 226 | |
| 227 | To run all tests including acceptance tests: |
| 228 | |
| 229 | ---- |
| 230 | buck test --all |
| 231 | ---- |
| 232 | |
| 233 | To exclude slow tests: |
| 234 | |
| 235 | ---- |
Shawn Pearce | 11d27c8 | 2013-07-24 08:09:31 -0700 | [diff] [blame] | 236 | buck test --all --exclude slow |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 237 | ---- |
| 238 | |
Edwin Kempin | 674078a | 2013-08-20 11:37:14 +0200 | [diff] [blame] | 239 | To run a specific test, e.g. the acceptance test |
| 240 | `com.google.gerrit.acceptance.git.HttpPushForReviewIT`: |
| 241 | |
| 242 | ---- |
| 243 | buck test //gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git:HttpPushForReviewIT |
| 244 | ---- |
| 245 | |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 246 | |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 247 | Dependencies |
| 248 | ------------ |
| 249 | |
| 250 | Dependency JARs are normally downloaded automatically, but Buck can inspect |
| 251 | its graph and download any missing JAR files. This is useful to enable |
Shawn Pearce | a7a3ee1 | 2013-09-20 10:42:37 -0700 | [diff] [blame] | 252 | subsequent builds to run without network access: |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 253 | |
| 254 | ---- |
Shawn Pearce | a7a3ee1 | 2013-09-20 10:42:37 -0700 | [diff] [blame] | 255 | tools/download_all.py |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 256 | ---- |
| 257 | |
David Pursehouse | b46cf49 | 2013-05-14 09:41:30 +0900 | [diff] [blame] | 258 | When downloading from behind a proxy (which is common in some corporate |
| 259 | environments), it might be necessary to explicitly specify the proxy that |
| 260 | is then used by `curl`: |
| 261 | |
| 262 | ---- |
| 263 | export http_proxy=http://<proxy_user_id>:<proxy_password>@<proxy_server>:<proxy_port> |
| 264 | ---- |
| 265 | |
Shawn Pearce | 1b89f85 | 2013-05-13 20:26:34 -0700 | [diff] [blame] | 266 | Redirection to local mirrors of Maven Central and the Gerrit storage |
| 267 | bucket is supported by defining specific properties in |
| 268 | `local.properties`, a file that is not tracked by Git: |
| 269 | |
| 270 | ---- |
| 271 | echo download.GERRIT = http://nexus.my-company.com/ >>local.properties |
| 272 | echo download.MAVEN_CENTRAL = http://nexus.my-company.com/ >>local.properties |
| 273 | ---- |
| 274 | |
David Pursehouse | 6fb2c4d | 2013-05-16 16:51:46 +0900 | [diff] [blame] | 275 | The `local.properties` file may be placed in the root of the gerrit repository |
| 276 | being built, or in `~/.gerritcodereview/`. The file in the root of the gerrit |
| 277 | repository has precedence. |
| 278 | |
David Ostrovsky | ee9f992 | 2013-08-15 00:21:04 +0200 | [diff] [blame] | 279 | Building against unpublished Maven JARs |
| 280 | --------------------------------------- |
| 281 | |
| 282 | To build against unpublished Maven JARs, like gwtorm or PrologCafe, the custom |
David Pursehouse | b99db5c | 2013-09-26 11:34:42 +0900 | [diff] [blame^] | 283 | JARs must be installed in the local Maven repository (`mvn clean install`) and |
| 284 | `maven_jar()` must be updated to point to the `MAVEN_LOCAL` Maven repository for |
David Ostrovsky | ee9f992 | 2013-08-15 00:21:04 +0200 | [diff] [blame] | 285 | that artifact: |
| 286 | |
David Pursehouse | b99db5c | 2013-09-26 11:34:42 +0900 | [diff] [blame^] | 287 | [source,python] |
David Ostrovsky | ee9f992 | 2013-08-15 00:21:04 +0200 | [diff] [blame] | 288 | ---- |
| 289 | maven_jar( |
| 290 | name = 'gwtorm', |
| 291 | id = 'gwtorm:gwtorm:42', |
David Ostrovsky | ee9f992 | 2013-08-15 00:21:04 +0200 | [diff] [blame] | 292 | license = 'Apache2.0', |
| 293 | repository = MAVEN_LOCAL, |
| 294 | ) |
| 295 | ---- |
| 296 | |
Shawn Pearce | 9e4e243 | 2013-05-30 13:09:29 -0700 | [diff] [blame] | 297 | Caching Build Results |
| 298 | ~~~~~~~~~~~~~~~~~~~~~ |
| 299 | |
| 300 | Build results can be locally cached, saving rebuild time when |
| 301 | switching between Git branches. Buck's documentation covers |
| 302 | caching in link:http://facebook.github.io/buck/concept/buckconfig.html[buckconfig]. |
| 303 | The trivial case using a local directory is: |
| 304 | |
| 305 | ---- |
| 306 | cat >.buckconfig.local <<EOF |
| 307 | [cache] |
| 308 | mode = dir |
| 309 | dir = buck-cache |
| 310 | EOF |
| 311 | ---- |
| 312 | |
Edwin Kempin | 9a8b1dc | 2013-09-16 09:08:34 +0200 | [diff] [blame] | 313 | [[buck-daemon]] |
David Ostrovsky | d5ae8d3 | 2013-09-15 20:10:17 +0200 | [diff] [blame] | 314 | Using Buck daemon |
| 315 | ~~~~~~~~~~~~~~~~~ |
| 316 | |
David Pursehouse | b99db5c | 2013-09-26 11:34:42 +0900 | [diff] [blame^] | 317 | Buck ships with a daemon command `buckd`, which uses the |
David Ostrovsky | d5ae8d3 | 2013-09-15 20:10:17 +0200 | [diff] [blame] | 318 | link:https://github.com/martylamb/nailgun[Nailgun] protocol for running |
| 319 | Java programs from the command line without incurring the JVM startup |
David Pursehouse | b99db5c | 2013-09-26 11:34:42 +0900 | [diff] [blame^] | 320 | overhead. |
| 321 | |
| 322 | Using a Buck daemon can save significant amounts of time as it avoids the |
| 323 | overhead of starting a Java virtual machine, loading the buck class files |
| 324 | and parsing the build files for each command. |
| 325 | |
| 326 | It is safe to run several buck daemons started from different project |
| 327 | directories and they will not interfere with each other. Buck's documentation |
| 328 | covers daemon in http://facebook.github.io/buck/command/buckd.html[buckd]. |
| 329 | |
| 330 | The trivial use case is to run `buckd` from the project's root directory and |
| 331 | run `buck` as usual: |
David Ostrovsky | d5ae8d3 | 2013-09-15 20:10:17 +0200 | [diff] [blame] | 332 | |
| 333 | ---- |
David Pursehouse | b99db5c | 2013-09-26 11:34:42 +0900 | [diff] [blame^] | 334 | buckd |
| 335 | buck build gerrit |
| 336 | Using buckd. |
| 337 | [-] PARSING BUILD FILES...FINISHED 0.6s |
| 338 | [-] BUILDING...FINISHED 0.2s |
David Ostrovsky | d5ae8d3 | 2013-09-15 20:10:17 +0200 | [diff] [blame] | 339 | ---- |
| 340 | |
David Ostrovsky | efaff30 | 2013-09-20 22:36:14 +0200 | [diff] [blame] | 341 | Overwrite Buck's settings |
| 342 | ~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 343 | |
| 344 | In the latest version of Buck the wrapper script `buck_common` will source |
| 345 | one of these files (if they exist): /etc/buck.conf, $HOME/.buck/buck.conf or |
| 346 | $HOME/.buckrc. The trivial case to overwrite the Buck's default 1GB heap size: |
| 347 | |
| 348 | ---- |
| 349 | cat > $HOME/.buckrc <<EOF |
| 350 | export BUCK_EXTRA_JAVA_ARGS="\ |
| 351 | -XX:MaxPermSize=512m \ |
| 352 | -Xms8000m \ |
| 353 | -Xmx16000m" |
| 354 | EOF |
| 355 | ---- |
| 356 | |
| 357 | Or to debug BUCK, set BUCK_DEBUG_MODE to anything non-empty, then connect to |
| 358 | port 8888: |
| 359 | |
| 360 | ---- |
| 361 | cat > $HOME/.buckrc <<EOF |
| 362 | export BUCK_DEBUG_MODE="yes" |
| 363 | EOF |
| 364 | ---- |
| 365 | |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 366 | GERRIT |
| 367 | ------ |
| 368 | Part of link:index.html[Gerrit Code Review] |