blob: 6bd3905dfb27531b50f66bab38f469c53c82fbdd [file] [log] [blame]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08001= Gerrit Code Review - Building with Buck
David Pursehoused0525a72013-05-09 17:49:34 +01002
3
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08004== Installation
David Pursehoused0525a72013-05-09 17:49:34 +01005
Deniz Türkoglud7559c02014-09-08 11:27:23 +02006Note that you need to use Java 7 for building gerrit.
7
David Pursehoused0525a72013-05-09 17:49:34 +01008There is currently no binary distribution of Buck, so it has to be manually
David Pursehouse64c16442013-05-14 10:49:03 +09009built and installed. Apache Ant is required. Currently only Linux and Mac
David Ostrovskye44706a2014-06-13 16:28:30 +020010OS are supported. Buck requires Python version 2.7 to be installed.
David Pursehoused0525a72013-05-09 17:49:34 +010011
12Clone the git and build it:
13
14----
15 git clone https://gerrit.googlesource.com/buck
16 cd buck
Shawn Pearce552c1b52014-11-27 11:48:28 -080017 git checkout $(cat ../gerrit/.buckversion)
David Pursehoused0525a72013-05-09 17:49:34 +010018 ant
19----
20
David Pursehousee9803ab2014-03-12 14:15:10 +090021If you don't have a `bin/` directory in your home directory, create one:
David Pursehoused0525a72013-05-09 17:49:34 +010022
23----
David Pursehouse64c16442013-05-14 10:49:03 +090024 mkdir ~/bin
David Pursehousee9803ab2014-03-12 14:15:10 +090025----
26
27Add the `~/bin` folder to the path:
28
29----
David Pursehouse64c16442013-05-14 10:49:03 +090030 PATH=~/bin:$PATH
David Pursehoused0525a72013-05-09 17:49:34 +010031----
32
David Pursehousee9803ab2014-03-12 14:15:10 +090033Note that the buck executable needs to be available in all shell sessions,
34so also make sure it is appended to the path globally.
35
David Pursehouse1d04f642014-09-10 11:09:02 +020036Add a symbolic link in `~/bin` to the buck and buckd executables:
David Pursehoused0525a72013-05-09 17:49:34 +010037
38----
David Pursehouse64c16442013-05-14 10:49:03 +090039 ln -s `pwd`/bin/buck ~/bin/
David Pursehouse1d04f642014-09-10 11:09:02 +020040 ln -s `pwd`/bin/buckd ~/bin/
David Pursehouse64c16442013-05-14 10:49:03 +090041----
42
David Pursehouse5c42b8c2013-05-17 13:25:47 +010043Verify that `buck` is accessible:
David Pursehouse64c16442013-05-14 10:49:03 +090044
45----
46 which buck
David Pursehoused0525a72013-05-09 17:49:34 +010047----
48
David Pursehousebe284992013-09-26 14:43:33 +090049To enable autocompletion of buck commands, install the autocompletion
David Pursehousead4ed962014-09-10 11:09:26 +020050script from `./scripts/buck_completion.bash` in the buck project. Refer
51to the script's header comments for installation instructions.
David Pursehousebe284992013-09-26 14:43:33 +090052
David Pursehoused0525a72013-05-09 17:49:34 +010053
David Pursehouse5861a9a2013-05-15 10:25:19 +090054[[eclipse]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080055== Eclipse Integration
David Pursehoused0525a72013-05-09 17:49:34 +010056
57
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080058=== Generating the Eclipse Project
David Pursehoused0525a72013-05-09 17:49:34 +010059
Shawn Pearcea7a3ee12013-09-20 10:42:37 -070060Create the Eclipse project:
David Pursehoused0525a72013-05-09 17:49:34 +010061
62----
Shawn Pearcea7a3ee12013-09-20 10:42:37 -070063 tools/eclipse/project.py
David Pursehoused0525a72013-05-09 17:49:34 +010064----
65
66In Eclipse, choose 'Import existing project' and select the `gerrit` project
Edwin Kempin0d687ff2013-06-14 09:41:07 +020067from the current working directory.
David Pursehoused0525a72013-05-09 17:49:34 +010068
69Expand the `gerrit` project, right-click on the `buck-out` folder, select
70'Properties', and then under 'Attributes' check 'Derived'.
71
Shawn Pearcea7a3ee12013-09-20 10:42:37 -070072Note that if you make any changes in the project configuration
73that get saved to the `.project` file, for example adding Resource
74Filters on a folder, they will be overwritten the next time you run
75`tools/eclipse/project.py`.
David Pursehouse38ba8802013-05-17 13:42:03 +010076
David Pursehouseb46cf492013-05-14 09:41:30 +090077
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080078=== Refreshing the Classpath
David Pursehoused0525a72013-05-09 17:49:34 +010079
Shawn Pearcea7a3ee12013-09-20 10:42:37 -070080If an updated classpath is needed, the Eclipse project can be
81refreshed and missing dependency JARs can be downloaded:
David Pursehoused0525a72013-05-09 17:49:34 +010082
83----
Shawn Pearcea7a3ee12013-09-20 10:42:37 -070084 tools/eclipse/project.py
David Pursehoused0525a72013-05-09 17:49:34 +010085----
86
87
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080088=== Attaching Sources
Shawn Pearce7b553262013-05-13 21:25:13 -070089
90To save time and bandwidth source JARs are only downloaded by the buck
91build where necessary to compile Java source into JavaScript using the
92GWT compiler. Additional sources may be obtained, allowing Eclipse to
93show documentation or dive into the implementation of a library JAR:
94
95----
Shawn Pearcea7a3ee12013-09-20 10:42:37 -070096 tools/eclipse/project.py --src
Shawn Pearce7b553262013-05-13 21:25:13 -070097----
98
99
David Pursehouse6de7ee22013-05-20 11:08:51 +0900100[[build]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800101== Building on the Command Line
David Pursehoused0525a72013-05-09 17:49:34 +0100102
103
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800104=== Gerrit Development WAR File
David Pursehoused0525a72013-05-09 17:49:34 +0100105
106To build the Gerrit web application:
107
108----
109 buck build gerrit
110----
111
112The output executable WAR will be placed in:
113
114----
115 buck-out/gen/gerrit.war
116----
117
118
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800119=== Extension and Plugin API JAR Files
David Pursehoused0525a72013-05-09 17:49:34 +0100120
David Ostrovskye5487a02013-11-25 00:00:13 +0100121To build the extension, plugin and GWT API JAR files:
David Pursehoused0525a72013-05-09 17:49:34 +0100122
123----
124 buck build api
125----
126
David Ostrovskye5487a02013-11-25 00:00:13 +0100127Java binaries, Java sources and Java docs are generated into corresponding
David Pursehouse43dc7482013-12-13 14:54:42 +0900128project directories in `buck-out/gen`, here as example for plugin API:
David Pursehoused0525a72013-05-09 17:49:34 +0100129
130----
David Ostrovskye5487a02013-11-25 00:00:13 +0100131 buck-out/gen/gerrit-plugin-api/plugin-api.jar
132 buck-out/gen/gerrit-plugin-api/plugin-api-src.jar
133 buck-out/gen/gerrit-plugin-api/plugin-api-javadoc.jar
David Pursehoused0525a72013-05-09 17:49:34 +0100134----
135
David Ostrovsky358a4582014-05-13 23:55:04 +0200136Install {extension,plugin,gwt}-api to the local maven repository:
David Ostrovsky6e6a9672013-05-30 01:10:12 +0200137
138----
139 buck build api_install
140----
141
David Ostrovsky358a4582014-05-13 23:55:04 +0200142Install gerrit.war to the local maven repository:
143
144----
145 buck build war_install
146----
147
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800148=== Plugins
David Pursehouse0bc51db2013-05-14 12:46:49 +0900149
150To build all core plugins:
151
152----
153 buck build plugins:core
154----
155
156The output JAR files for individual plugins will be placed in:
157
158----
159 buck-out/gen/plugins/<name>/<name>.jar
160----
161
162The JAR files will also be packaged in:
163
164----
165 buck-out/gen/plugins/core.zip
166----
167
168To build a specific plugin:
169
170----
Shawn Pearce6586c202013-11-09 08:54:48 -0800171 buck build plugins/<name>:<name>
David Pursehouse0bc51db2013-05-14 12:46:49 +0900172----
173
174The output JAR file will be be placed in:
175
176----
177 buck-out/gen/plugins/<name>/<name>.jar
178----
179
180Note that when building an individual plugin, the `core.zip` package
181is not regenerated.
182
Shawn Pearce6586c202013-11-09 08:54:48 -0800183Additional plugins with BUCK files can be added to the build
184environment by cloning the source repository into the plugins
185subdirectory:
186
187----
188 git clone https://gerrit.googlesource.com/plugins/<name> plugins/<name>
189 echo /plugins/<name> >>.git/info/exclude
190----
191
192Additional plugin sources will be automatically added to Eclipse the
193next time project.py is run:
194
195----
196 tools/eclipse/project.py
197----
198
David Pursehouse90a9c102013-09-06 18:42:10 +0900199
200[[documentation]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800201=== Documentation
David Pursehouse90a9c102013-09-06 18:42:10 +0900202
Yuxuan 'fishy' Wangf7803972014-09-03 12:23:21 -0700203To build only the documentation for testing or static hosting:
David Pursehouse90a9c102013-09-06 18:42:10 +0900204
205----
206 buck build docs
207----
208
Yuxuan 'fishy' Wangf7803972014-09-03 12:23:21 -0700209The generated html files will NOT come with the search box, and will be
210placed in:
David Pursehouse90a9c102013-09-06 18:42:10 +0900211
212----
Yuxuan 'fishy' Wangf7803972014-09-03 12:23:21 -0700213 buck-out/gen/Documentation/searchfree__tmp/Documentation
David Pursehouse90a9c102013-09-06 18:42:10 +0900214----
215
Yuxuan 'fishy' Wangf7803972014-09-03 12:23:21 -0700216The html files will also be bundled into `searchfree.zip` in this location:
David Pursehouse90a9c102013-09-06 18:42:10 +0900217
David Ostrovsky7cd233e2013-09-26 07:21:31 +0200218----
Yuxuan 'fishy' Wangf7803972014-09-03 12:23:21 -0700219 buck-out/gen/Documentation/searchfree.zip
David Ostrovsky7cd233e2013-09-26 07:21:31 +0200220----
David Pursehouse90a9c102013-09-06 18:42:10 +0900221
David Pursehousec08d03e2013-12-10 18:16:10 +0900222To build the executable WAR with the documentation included:
223
224----
225 buck build withdocs
226----
227
228The WAR file will be placed in:
229
230----
231 buck-out/gen/withdocs.war
232----
233
Shawn Pearce16570462015-01-14 16:27:42 -0800234[[soyc]]
235=== GWT Compile Report
236
237The GWT compiler can output a compile report (or "story of your compile"),
238describing the size of the JavaScript and which source classes contributed
239to the overall download size.
240
241----
242 buck build soyc
243----
244
245The report will be written as an HTML page to the extras directory, and
246can be opened and viewed in any web browser:
247
248----
249 extras/gerrit_ui/soycReport/compile-report/index.html
250----
251
252Only the "Split Point Report" is created, "Compiler Metrics" are not output.
253
David Ostrovsky811e6032013-09-06 08:35:45 +0200254[[release]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800255=== Gerrit Release WAR File
David Ostrovsky811e6032013-09-06 08:35:45 +0200256
257To build the release of the Gerrit web application, including documentation and
258all core plugins:
259
260----
261 buck build release
262----
263
264The output release WAR will be placed in:
265
266----
267 buck-out/gen/release.war
268----
David Pursehouse0bc51db2013-05-14 12:46:49 +0900269
David Ostrovskye64e30d2014-03-25 06:25:56 -0700270[[all]]
271=== Combined build target
272
273To build release and api targets, a combined build target is provided:
274
275----
276 buck build all
277----
278
David Pursehouse5861a9a2013-05-15 10:25:19 +0900279[[tests]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800280== Running Unit Tests
David Pursehoused0525a72013-05-09 17:49:34 +0100281
282To run all tests including acceptance tests:
283
284----
David Ostrovsky530a4c32014-06-25 00:36:59 +0200285 buck test
David Pursehoused0525a72013-05-09 17:49:34 +0100286----
287
288To exclude slow tests:
289
290----
Shawn Pearce11d27c82013-07-24 08:09:31 -0700291 buck test --all --exclude slow
David Pursehoused0525a72013-05-09 17:49:34 +0100292----
293
David Ostrovskyc4e0ac62014-04-21 18:25:18 +0200294To include a specific group of acceptance tests:
295
296----
297 buck test --all --include api
298----
299
300The following groups of tests are currently supported:
301
302* api
David Ostrovsky4efb0f22014-12-18 08:55:13 +0100303* edit
David Ostrovskyc4e0ac62014-04-21 18:25:18 +0200304* git
305* pgm
306* rest
307* server
308* ssh
309
Edwin Kempin674078a2013-08-20 11:37:14 +0200310To run a specific test, e.g. the acceptance test
311`com.google.gerrit.acceptance.git.HttpPushForReviewIT`:
312
313----
314 buck test //gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git:HttpPushForReviewIT
315----
316
David Ostrovskyfaec8052014-08-10 00:32:52 +0200317To create test coverage report:
318
319----
320 buck test --code-coverage --code-coverage-format html --no-results-cache
321----
322
323The HTML report is created in `buck-out/gen/jacoco/code-coverage/index.html`.
David Pursehoused0525a72013-05-09 17:49:34 +0100324
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800325== Dependencies
David Pursehoused0525a72013-05-09 17:49:34 +0100326
327Dependency JARs are normally downloaded automatically, but Buck can inspect
328its graph and download any missing JAR files. This is useful to enable
Shawn Pearcea7a3ee12013-09-20 10:42:37 -0700329subsequent builds to run without network access:
David Pursehoused0525a72013-05-09 17:49:34 +0100330
331----
Shawn Pearcea7a3ee12013-09-20 10:42:37 -0700332 tools/download_all.py
David Pursehoused0525a72013-05-09 17:49:34 +0100333----
334
David Pursehouseb46cf492013-05-14 09:41:30 +0900335When downloading from behind a proxy (which is common in some corporate
336environments), it might be necessary to explicitly specify the proxy that
337is then used by `curl`:
338
339----
340 export http_proxy=http://<proxy_user_id>:<proxy_password>@<proxy_server>:<proxy_port>
341----
342
Shawn Pearce1b89f852013-05-13 20:26:34 -0700343Redirection to local mirrors of Maven Central and the Gerrit storage
344bucket is supported by defining specific properties in
345`local.properties`, a file that is not tracked by Git:
346
347----
348 echo download.GERRIT = http://nexus.my-company.com/ >>local.properties
349 echo download.MAVEN_CENTRAL = http://nexus.my-company.com/ >>local.properties
350----
351
David Pursehouse6fb2c4d2013-05-16 16:51:46 +0900352The `local.properties` file may be placed in the root of the gerrit repository
353being built, or in `~/.gerritcodereview/`. The file in the root of the gerrit
354repository has precedence.
355
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800356== Building against unpublished Maven JARs
David Ostrovskyee9f9922013-08-15 00:21:04 +0200357
358To build against unpublished Maven JARs, like gwtorm or PrologCafe, the custom
David Pursehouseb99db5c2013-09-26 11:34:42 +0900359JARs must be installed in the local Maven repository (`mvn clean install`) and
360`maven_jar()` must be updated to point to the `MAVEN_LOCAL` Maven repository for
David Ostrovskyee9f9922013-08-15 00:21:04 +0200361that artifact:
362
David Pursehouseb99db5c2013-09-26 11:34:42 +0900363[source,python]
David Ostrovskyee9f9922013-08-15 00:21:04 +0200364----
365 maven_jar(
366 name = 'gwtorm',
367 id = 'gwtorm:gwtorm:42',
David Ostrovskyee9f9922013-08-15 00:21:04 +0200368 license = 'Apache2.0',
369 repository = MAVEN_LOCAL,
370 )
371----
372
David Ostrovsky07df9592014-02-01 23:47:22 +0100373== Building against unpublished JARs, that change frequently
374
375If a dependent Gerrit library is undergoing active development it must be
376recompiled and the change must be reflected in the Buck build process. For
377example testing Gerrit against changed JGit snapshot version. After building
378JGit library, the artifacts are created in local Maven build directory, e. g.:
379
380----
381 mvn package
382 /home/<user>/projects/jgit/org.eclipse.jgit/target/org.eclipse.jgit-3.3.0-SNAPSHOT.jar
383 /home/<user>/projects/jgit/org.eclipse.jgit/target/org.eclipse.jgit-3.3.0-SNAPSHOT-sources.jar
384----
385
386If as usual, installation of the build artifacts takes place in local maven
387repository, then the Buck build must fetch them from there with normal
388`download_file.py` process. Disadvantage of this approach is that Buck cache
389invalidation must occur to refresh the artifacts after next
390change-compile-install round trip.
391
392To shorten that workflow and take the installation of the artifacts to the
393local Maven repository and fetching it again from there out of the picture,
394`local_jar()` method is used instead of `maven_jar()`:
395
396[source,python]
397----
398 local_jar(
399 name = 'jgit',
400 jar = '/home/<user>/projects/jgit/org.eclipse.jgit/target/org.eclipse.jgit-3.3.0-SNAPSHOT.jar',
401 src = '/home/<user>/projects/jgit/org.eclipse.jgit/target/org.eclipse.jgit-3.3.0-SNAPSHOT-sources.jar',
402 deps = [':ewah']
403 )
404----
405
406This creates a symlink to the Buck targets direct against artifacts in
407another project's Maven target directory:
408
409----
410 buck-out/gen/lib/jgit/jgit.jar ->
411 /home/<user>/projects/jgit/org.eclipse.jgit/target/org.eclipse.jgit-3.3.0-SNAPSHOT.jar
412----
413
David Ostrovsky1a1b8b8a2014-10-23 22:37:58 +0200414After `buck clean` and `buck build lib/jgit:jgit` the symbolic link that was
415created the first time is lost due to Buck's caching mechanism. This means that
416when a new version of the local artifact is deployed (by running `mvn package`
417in the JGit project in the example above), Buck is not aware of it, because it
418still has a stale version of it in its cache.
419
420To solve this problem and re-create the symbolic link, you don't need to wipe out
421the entire Buck cache. Just rebuilding the target with the `--no-cache` option
422does the job:
423
424----
425 buck clean
426 buck build --no-cache lib/jgit:jgit
427----
428
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800429== Building against artifacts from custom Maven repositories
David Ostrovsky2536d062013-11-14 00:35:07 +0100430
431To build against custom Maven repositories, two modes of operations are
432supported: with rewrite in local.properties and without.
433
434Without rewrite the URL of custom Maven repository can be directly passed
435to the maven_jar() function:
436
437[source,python]
438----
439 GERRIT_FORGE = 'http://gerritforge.com/snapshot'
440
441 maven_jar(
442 name = 'gitblit',
443 id = 'com.gitblit:gitblit:1.4.0',
444 sha1 = '1b130dbf5578ace37507430a4a523f6594bf34fa',
445 license = 'Apache2.0',
446 repository = GERRIT_FORGE,
447 )
448----
449
450When the custom URL has to be rewritten, then the same logic as with Gerrit
451known Maven repository is used: Repo name must be defined that matches an entry
452in local.properties file:
453
454----
455 download.GERRIT_FORGE = http://my.company.mirror/gerrit-forge
456----
457
458And corresponding BUCK excerpt:
459
460[source,python]
461----
462 GERRIT_FORGE = 'GERRIT_FORGE:'
463
464 maven_jar(
465 name = 'gitblit',
466 id = 'com.gitblit:gitblit:1.4.0',
467 sha1 = '1b130dbf5578ace37507430a4a523f6594bf34fa',
468 license = 'Apache2.0',
469 repository = GERRIT_FORGE,
470 )
471----
472
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800473=== Caching Build Results
Shawn Pearce9e4e2432013-05-30 13:09:29 -0700474
475Build results can be locally cached, saving rebuild time when
476switching between Git branches. Buck's documentation covers
477caching in link:http://facebook.github.io/buck/concept/buckconfig.html[buckconfig].
478The trivial case using a local directory is:
479
480----
481 cat >.buckconfig.local <<EOF
482 [cache]
483 mode = dir
484 dir = buck-cache
485 EOF
486----
487
David Pursehouse6c3fd802014-10-24 13:50:44 +0900488[[clean-cache]]
489=== Cleaning The Buck Cache
490
491The cache for the Gerrit Code Review project is located in
492`~/.gerritcodereview/buck-cache/cache`.
493
494The Buck cache should never need to be manually deleted. If you find yourself
495deleting the Buck cache regularly, then it is likely that there is something
496wrong with your environment or your workflow.
497
498If you really do need to clean the cache manually, then:
499
500----
501 rm -rf ~/.gerritcodereview/buck-cache/cache
502----
503
504Note that the root `buck-cache` folder should not be deleted as this is where
505downloaded artifacts are stored.
506
Edwin Kempin9a8b1dc2013-09-16 09:08:34 +0200507[[buck-daemon]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800508=== Using Buck daemon
David Ostrovskyd5ae8d32013-09-15 20:10:17 +0200509
David Pursehouseb99db5c2013-09-26 11:34:42 +0900510Buck ships with a daemon command `buckd`, which uses the
David Ostrovskyd5ae8d32013-09-15 20:10:17 +0200511link:https://github.com/martylamb/nailgun[Nailgun] protocol for running
512Java programs from the command line without incurring the JVM startup
David Pursehouseb99db5c2013-09-26 11:34:42 +0900513overhead.
514
515Using a Buck daemon can save significant amounts of time as it avoids the
516overhead of starting a Java virtual machine, loading the buck class files
517and parsing the build files for each command.
518
519It is safe to run several buck daemons started from different project
520directories and they will not interfere with each other. Buck's documentation
521covers daemon in http://facebook.github.io/buck/command/buckd.html[buckd].
522
David Ostrovsky26e3be62014-05-23 08:34:07 +0200523To use `buckd` the additional
524link:https://facebook.github.io/watchman[watchman] program must be installed.
525
David Ostrovsky37175422014-09-22 09:55:40 +0200526To disable `buckd`, the environment variable `NO_BUCKD` must be set. It's not
527recommended to put it in the shell config, as it can be forgotten about it and
528then assumed Buck was working as it should when it should be using buckd.
529Prepend the variable to Buck invocation instead:
530
531----
David Pursehouse8d4d3162014-10-24 13:57:06 +0900532 NO_BUCKD=1 buck build gerrit
David Ostrovsky37175422014-09-22 09:55:40 +0200533----
534
David Ostrovsky26e3be62014-05-23 08:34:07 +0200535[[watchman]]
536=== Installing watchman
537
538Watchman is used internally by Buck to monitor directory trees and is needed
539for buck daemon to work properly. Because buckd is activated by default in the
540latest version of Buck, it searches for the watchman executable in the
541path and issues a warning when it is not found and kills buckd.
542
543To prepare watchman installation on Linux:
David Ostrovskyd5ae8d32013-09-15 20:10:17 +0200544
545----
David Ostrovsky26e3be62014-05-23 08:34:07 +0200546 git clone https://github.com/facebook/watchman.git
547 cd watchman
548 ./autogen.sh
David Ostrovskyd5ae8d32013-09-15 20:10:17 +0200549----
550
David Ostrovsky26e3be62014-05-23 08:34:07 +0200551To install it in user home directory (without root privileges):
552
553----
554 ./configure --prefix $HOME/watchman
555 make install
556----
557
558To install it system wide:
559
560----
561 ./configure
562 make
563 sudo make install
564----
565
566Put $HOME/watchman/bin/watchman in path or link to $HOME/bin/watchman.
567
568To install watchman on OS X:
569
570----
571 brew install --HEAD watchman
572----
573
574See the original documentation for more information:
575link:https://facebook.github.io/watchman/docs/install.html[Watchman
576installation].
577
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800578=== Override Buck's settings
David Ostrovskyefaff302013-09-20 22:36:14 +0200579
Shawn Pearce4e1a8bc2013-11-28 18:38:30 -0800580Additional JVM args for Buck can be set in `.buckjavaargs` in the
581project root directory. For example to override Buck's default 1GB
582heap size:
David Ostrovskyefaff302013-09-20 22:36:14 +0200583
584----
Shawn Pearce4e1a8bc2013-11-28 18:38:30 -0800585 cat > .buckjavaargs <<EOF
586 -XX:MaxPermSize=512m -Xms8000m -Xmx16000m
David Ostrovskyefaff302013-09-20 22:36:14 +0200587 EOF
588----
589
David Ostrovskyfe2934e2014-04-22 00:36:12 +0200590== Rerun unit tests
David Ostrovskya4ea92e72014-03-25 06:42:33 -0700591
David Pursehouse56f60a42014-07-10 11:20:33 +0900592Test execution results are cached by Buck. If a test that was already run
593needs to be repeated, the unit test cache for that test must be removed first:
David Ostrovskya4ea92e72014-03-25 06:42:33 -0700594
595----
David Pursehouse8d4d3162014-10-24 13:57:06 +0900596 rm -rf buck-out/bin/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/group/.AddRemoveGroupMembersIT/
David Ostrovskya4ea92e72014-03-25 06:42:33 -0700597----
598
David Pursehouse56f60a42014-07-10 11:20:33 +0900599After clearing the cache, the test can be run again:
David Ostrovskya4ea92e72014-03-25 06:42:33 -0700600
601----
David Pursehouse8d4d3162014-10-24 13:57:06 +0900602 buck test //gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/group:AddRemoveGroupMembersIT
David Ostrovskya4ea92e72014-03-25 06:42:33 -0700603 TESTING //gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/group:AddRemoveGroupMembersIT
604 PASS 14,9s 8 Passed 0 Failed com.google.gerrit.acceptance.rest.group.AddRemoveGroupMembersIT
605 TESTS PASSED
606----
607
David Pursehouse56f60a42014-07-10 11:20:33 +0900608An alternative approach is to use Buck's `--filters` (`-f`) option:
David Ostrovskya4ea92e72014-03-25 06:42:33 -0700609
610----
David Pursehouse56f60a42014-07-10 11:20:33 +0900611 buck test -f 'com.google.gerrit.acceptance.rest.change.SubmitByMergeAlwaysIT'
David Ostrovskya4ea92e72014-03-25 06:42:33 -0700612 TESTING SELECTED TESTS
613 PASS 14,5s 6 Passed 0 Failed com.google.gerrit.acceptance.rest.change.SubmitByMergeAlwaysIT
614 TESTS PASSED
615----
616
David Pursehouse56f60a42014-07-10 11:20:33 +0900617When this option is used, the cache is disabled per design and doesn't need to
618be explicitly deleted.
619
620Note that when this option is used, the whole unit test cache is dropped, so
David Ostrovsky074859e2014-04-19 22:52:47 +0200621repeating the
622
623----
David Pursehouse56f60a42014-07-10 11:20:33 +0900624buck test
David Ostrovsky074859e2014-04-19 22:52:47 +0200625----
626
David Pursehouse56f60a42014-07-10 11:20:33 +0900627causes all tests to be executed again.
628
629To run tests without using cached results at all, use the `--no-results-cache`
630option:
631
632----
633buck test --no-results-cache
634----
David Ostrovskya4ea92e72014-03-25 06:42:33 -0700635
David Pursehouse226eaf32014-12-18 17:49:28 +0900636== Troubleshooting Buck
637
638In some cases problems with Buck itself need to be investigated. See for example
639link:https://gerrit-review.googlesource.com/62411[this attempt to upgrade Buck]
640and link:https://github.com/facebook/buck/pull/227[the fix that was needed] to
641make the update possible.
642
643To build Gerrit with a custom version of Buck, the following steps are necessary:
644
6451. In the Buck git apply any necessary changes from pull requests
6462. Compile Buck with `ant`
6473. In the root of the Gerrit project create a `.nobuckcheck` file to prevent Buck
648from updating itself
6494. Replace the sha1 in Gerrit's `.buckversion` file with the required version from
650the custom Buck build
6515. Build Gerrit as usual
652
David Pursehoused0525a72013-05-09 17:49:34 +0100653GERRIT
654------
655Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700656
657SEARCHBOX
658---------