blob: bbc9ae25f385b2eacc74bb45488b4185d3eb8157 [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 Ostrovsky69349b42015-04-20 06:56:30 +020010OS are supported.
David Pursehoused0525a72013-05-09 17:49:34 +010011
12Clone the git and build it:
13
14----
David Pursehouse3e028c92015-04-16 16:00:59 +090015 git clone https://github.com/facebook/buck
David Pursehoused0525a72013-05-09 17:49:34 +010016 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 Ostrovsky69349b42015-04-20 06:56:30 +020053== Prerequisites
54
55Buck requires Python version 2.7 to be installed. The Maven download toolchain
56requires `curl` to be installed.
David Pursehoused0525a72013-05-09 17:49:34 +010057
David Pursehouse5861a9a2013-05-15 10:25:19 +090058[[eclipse]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080059== Eclipse Integration
David Pursehoused0525a72013-05-09 17:49:34 +010060
61
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080062=== Generating the Eclipse Project
David Pursehoused0525a72013-05-09 17:49:34 +010063
Shawn Pearcea7a3ee12013-09-20 10:42:37 -070064Create the Eclipse project:
David Pursehoused0525a72013-05-09 17:49:34 +010065
66----
Shawn Pearcea7a3ee12013-09-20 10:42:37 -070067 tools/eclipse/project.py
David Pursehoused0525a72013-05-09 17:49:34 +010068----
69
70In Eclipse, choose 'Import existing project' and select the `gerrit` project
Edwin Kempin0d687ff2013-06-14 09:41:07 +020071from the current working directory.
David Pursehoused0525a72013-05-09 17:49:34 +010072
73Expand the `gerrit` project, right-click on the `buck-out` folder, select
74'Properties', and then under 'Attributes' check 'Derived'.
75
Shawn Pearcea7a3ee12013-09-20 10:42:37 -070076Note that if you make any changes in the project configuration
77that get saved to the `.project` file, for example adding Resource
78Filters on a folder, they will be overwritten the next time you run
79`tools/eclipse/project.py`.
David Pursehouse38ba8802013-05-17 13:42:03 +010080
David Pursehouseb46cf492013-05-14 09:41:30 +090081
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080082=== Refreshing the Classpath
David Pursehoused0525a72013-05-09 17:49:34 +010083
Shawn Pearcea7a3ee12013-09-20 10:42:37 -070084If an updated classpath is needed, the Eclipse project can be
85refreshed and missing dependency JARs can be downloaded:
David Pursehoused0525a72013-05-09 17:49:34 +010086
87----
Shawn Pearcea7a3ee12013-09-20 10:42:37 -070088 tools/eclipse/project.py
David Pursehoused0525a72013-05-09 17:49:34 +010089----
90
91
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080092=== Attaching Sources
Shawn Pearce7b553262013-05-13 21:25:13 -070093
94To save time and bandwidth source JARs are only downloaded by the buck
95build where necessary to compile Java source into JavaScript using the
96GWT compiler. Additional sources may be obtained, allowing Eclipse to
97show documentation or dive into the implementation of a library JAR:
98
99----
Shawn Pearcea7a3ee12013-09-20 10:42:37 -0700100 tools/eclipse/project.py --src
Shawn Pearce7b553262013-05-13 21:25:13 -0700101----
102
103
David Pursehouse6de7ee22013-05-20 11:08:51 +0900104[[build]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800105== Building on the Command Line
David Pursehoused0525a72013-05-09 17:49:34 +0100106
107
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800108=== Gerrit Development WAR File
David Pursehoused0525a72013-05-09 17:49:34 +0100109
110To build the Gerrit web application:
111
112----
113 buck build gerrit
114----
115
116The output executable WAR will be placed in:
117
118----
119 buck-out/gen/gerrit.war
120----
121
122
David Ostrovsky7a295332015-02-27 19:19:45 +0100123=== Headless Mode
124
125To build Gerrit in headless mode, i.e. without the GWT Web UI:
126
127----
128 buck build headless
129----
130
131The output executable WAR will be placed in:
132
133----
134 buck-out/gen/headless.war
135----
136
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800137=== Extension and Plugin API JAR Files
David Pursehoused0525a72013-05-09 17:49:34 +0100138
David Ostrovskye5487a02013-11-25 00:00:13 +0100139To build the extension, plugin and GWT API JAR files:
David Pursehoused0525a72013-05-09 17:49:34 +0100140
141----
142 buck build api
143----
144
David Ostrovskye5487a02013-11-25 00:00:13 +0100145Java binaries, Java sources and Java docs are generated into corresponding
David Pursehouse43dc7482013-12-13 14:54:42 +0900146project directories in `buck-out/gen`, here as example for plugin API:
David Pursehoused0525a72013-05-09 17:49:34 +0100147
148----
David Ostrovskye5487a02013-11-25 00:00:13 +0100149 buck-out/gen/gerrit-plugin-api/plugin-api.jar
150 buck-out/gen/gerrit-plugin-api/plugin-api-src.jar
151 buck-out/gen/gerrit-plugin-api/plugin-api-javadoc.jar
David Pursehoused0525a72013-05-09 17:49:34 +0100152----
153
David Ostrovsky358a4582014-05-13 23:55:04 +0200154Install {extension,plugin,gwt}-api to the local maven repository:
David Ostrovsky6e6a9672013-05-30 01:10:12 +0200155
156----
157 buck build api_install
158----
159
David Ostrovsky358a4582014-05-13 23:55:04 +0200160Install gerrit.war to the local maven repository:
161
162----
163 buck build war_install
164----
165
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800166=== Plugins
David Pursehouse0bc51db2013-05-14 12:46:49 +0900167
168To build all core plugins:
169
170----
171 buck build plugins:core
172----
173
174The output JAR files for individual plugins will be placed in:
175
176----
177 buck-out/gen/plugins/<name>/<name>.jar
178----
179
180The JAR files will also be packaged in:
181
182----
183 buck-out/gen/plugins/core.zip
184----
185
186To build a specific plugin:
187
188----
Shawn Pearce6586c202013-11-09 08:54:48 -0800189 buck build plugins/<name>:<name>
David Pursehouse0bc51db2013-05-14 12:46:49 +0900190----
191
192The output JAR file will be be placed in:
193
194----
195 buck-out/gen/plugins/<name>/<name>.jar
196----
197
198Note that when building an individual plugin, the `core.zip` package
199is not regenerated.
200
Shawn Pearce6586c202013-11-09 08:54:48 -0800201Additional plugins with BUCK files can be added to the build
202environment by cloning the source repository into the plugins
203subdirectory:
204
205----
206 git clone https://gerrit.googlesource.com/plugins/<name> plugins/<name>
207 echo /plugins/<name> >>.git/info/exclude
208----
209
210Additional plugin sources will be automatically added to Eclipse the
211next time project.py is run:
212
213----
214 tools/eclipse/project.py
215----
216
David Pursehouse90a9c102013-09-06 18:42:10 +0900217
218[[documentation]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800219=== Documentation
David Pursehouse90a9c102013-09-06 18:42:10 +0900220
Yuxuan 'fishy' Wangf7803972014-09-03 12:23:21 -0700221To build only the documentation for testing or static hosting:
David Pursehouse90a9c102013-09-06 18:42:10 +0900222
223----
224 buck build docs
225----
226
Yuxuan 'fishy' Wangf7803972014-09-03 12:23:21 -0700227The generated html files will NOT come with the search box, and will be
228placed in:
David Pursehouse90a9c102013-09-06 18:42:10 +0900229
230----
Yuxuan 'fishy' Wangf7803972014-09-03 12:23:21 -0700231 buck-out/gen/Documentation/searchfree__tmp/Documentation
David Pursehouse90a9c102013-09-06 18:42:10 +0900232----
233
Yuxuan 'fishy' Wangf7803972014-09-03 12:23:21 -0700234The html files will also be bundled into `searchfree.zip` in this location:
David Pursehouse90a9c102013-09-06 18:42:10 +0900235
David Ostrovsky7cd233e2013-09-26 07:21:31 +0200236----
Yuxuan 'fishy' Wangf7803972014-09-03 12:23:21 -0700237 buck-out/gen/Documentation/searchfree.zip
David Ostrovsky7cd233e2013-09-26 07:21:31 +0200238----
David Pursehouse90a9c102013-09-06 18:42:10 +0900239
David Pursehousec08d03e2013-12-10 18:16:10 +0900240To build the executable WAR with the documentation included:
241
242----
243 buck build withdocs
244----
245
246The WAR file will be placed in:
247
248----
249 buck-out/gen/withdocs.war
250----
251
Shawn Pearce16570462015-01-14 16:27:42 -0800252[[soyc]]
253=== GWT Compile Report
254
255The GWT compiler can output a compile report (or "story of your compile"),
256describing the size of the JavaScript and which source classes contributed
257to the overall download size.
258
259----
260 buck build soyc
261----
262
263The report will be written as an HTML page to the extras directory, and
264can be opened and viewed in any web browser:
265
266----
267 extras/gerrit_ui/soycReport/compile-report/index.html
268----
269
270Only the "Split Point Report" is created, "Compiler Metrics" are not output.
271
David Ostrovsky811e6032013-09-06 08:35:45 +0200272[[release]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800273=== Gerrit Release WAR File
David Ostrovsky811e6032013-09-06 08:35:45 +0200274
275To build the release of the Gerrit web application, including documentation and
276all core plugins:
277
278----
279 buck build release
280----
281
282The output release WAR will be placed in:
283
284----
285 buck-out/gen/release.war
286----
David Pursehouse0bc51db2013-05-14 12:46:49 +0900287
David Ostrovskye64e30d2014-03-25 06:25:56 -0700288[[all]]
289=== Combined build target
290
291To build release and api targets, a combined build target is provided:
292
293----
294 buck build all
295----
296
David Pursehouse5861a9a2013-05-15 10:25:19 +0900297[[tests]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800298== Running Unit Tests
David Pursehoused0525a72013-05-09 17:49:34 +0100299
300To run all tests including acceptance tests:
301
302----
David Ostrovsky530a4c32014-06-25 00:36:59 +0200303 buck test
David Pursehoused0525a72013-05-09 17:49:34 +0100304----
305
306To exclude slow tests:
307
308----
Shawn Pearce11d27c82013-07-24 08:09:31 -0700309 buck test --all --exclude slow
David Pursehoused0525a72013-05-09 17:49:34 +0100310----
311
David Ostrovskyc4e0ac62014-04-21 18:25:18 +0200312To include a specific group of acceptance tests:
313
314----
315 buck test --all --include api
316----
317
318The following groups of tests are currently supported:
319
320* api
David Ostrovsky4efb0f22014-12-18 08:55:13 +0100321* edit
David Ostrovskyc4e0ac62014-04-21 18:25:18 +0200322* git
323* pgm
324* rest
325* server
326* ssh
327
Edwin Kempin674078a2013-08-20 11:37:14 +0200328To run a specific test, e.g. the acceptance test
329`com.google.gerrit.acceptance.git.HttpPushForReviewIT`:
330
331----
332 buck test //gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git:HttpPushForReviewIT
333----
334
David Ostrovskyfaec8052014-08-10 00:32:52 +0200335To create test coverage report:
336
337----
338 buck test --code-coverage --code-coverage-format html --no-results-cache
339----
340
341The HTML report is created in `buck-out/gen/jacoco/code-coverage/index.html`.
David Pursehoused0525a72013-05-09 17:49:34 +0100342
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800343== Dependencies
David Pursehoused0525a72013-05-09 17:49:34 +0100344
345Dependency JARs are normally downloaded automatically, but Buck can inspect
346its graph and download any missing JAR files. This is useful to enable
Shawn Pearcea7a3ee12013-09-20 10:42:37 -0700347subsequent builds to run without network access:
David Pursehoused0525a72013-05-09 17:49:34 +0100348
349----
Shawn Pearcea7a3ee12013-09-20 10:42:37 -0700350 tools/download_all.py
David Pursehoused0525a72013-05-09 17:49:34 +0100351----
352
David Pursehouseb46cf492013-05-14 09:41:30 +0900353When downloading from behind a proxy (which is common in some corporate
354environments), it might be necessary to explicitly specify the proxy that
355is then used by `curl`:
356
357----
358 export http_proxy=http://<proxy_user_id>:<proxy_password>@<proxy_server>:<proxy_port>
359----
360
Shawn Pearce1b89f852013-05-13 20:26:34 -0700361Redirection to local mirrors of Maven Central and the Gerrit storage
362bucket is supported by defining specific properties in
363`local.properties`, a file that is not tracked by Git:
364
365----
366 echo download.GERRIT = http://nexus.my-company.com/ >>local.properties
367 echo download.MAVEN_CENTRAL = http://nexus.my-company.com/ >>local.properties
368----
369
David Pursehouse6fb2c4d2013-05-16 16:51:46 +0900370The `local.properties` file may be placed in the root of the gerrit repository
371being built, or in `~/.gerritcodereview/`. The file in the root of the gerrit
372repository has precedence.
373
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800374== Building against unpublished Maven JARs
David Ostrovskyee9f9922013-08-15 00:21:04 +0200375
376To build against unpublished Maven JARs, like gwtorm or PrologCafe, the custom
David Pursehouseb99db5c2013-09-26 11:34:42 +0900377JARs must be installed in the local Maven repository (`mvn clean install`) and
378`maven_jar()` must be updated to point to the `MAVEN_LOCAL` Maven repository for
David Ostrovskyee9f9922013-08-15 00:21:04 +0200379that artifact:
380
David Pursehouseb99db5c2013-09-26 11:34:42 +0900381[source,python]
David Ostrovskyee9f9922013-08-15 00:21:04 +0200382----
383 maven_jar(
384 name = 'gwtorm',
385 id = 'gwtorm:gwtorm:42',
David Ostrovskyee9f9922013-08-15 00:21:04 +0200386 license = 'Apache2.0',
387 repository = MAVEN_LOCAL,
388 )
389----
390
David Ostrovsky07df9592014-02-01 23:47:22 +0100391== Building against unpublished JARs, that change frequently
392
393If a dependent Gerrit library is undergoing active development it must be
394recompiled and the change must be reflected in the Buck build process. For
395example testing Gerrit against changed JGit snapshot version. After building
396JGit library, the artifacts are created in local Maven build directory, e. g.:
397
398----
399 mvn package
400 /home/<user>/projects/jgit/org.eclipse.jgit/target/org.eclipse.jgit-3.3.0-SNAPSHOT.jar
401 /home/<user>/projects/jgit/org.eclipse.jgit/target/org.eclipse.jgit-3.3.0-SNAPSHOT-sources.jar
402----
403
404If as usual, installation of the build artifacts takes place in local maven
405repository, then the Buck build must fetch them from there with normal
406`download_file.py` process. Disadvantage of this approach is that Buck cache
407invalidation must occur to refresh the artifacts after next
408change-compile-install round trip.
409
410To shorten that workflow and take the installation of the artifacts to the
411local Maven repository and fetching it again from there out of the picture,
412`local_jar()` method is used instead of `maven_jar()`:
413
414[source,python]
415----
416 local_jar(
417 name = 'jgit',
418 jar = '/home/<user>/projects/jgit/org.eclipse.jgit/target/org.eclipse.jgit-3.3.0-SNAPSHOT.jar',
419 src = '/home/<user>/projects/jgit/org.eclipse.jgit/target/org.eclipse.jgit-3.3.0-SNAPSHOT-sources.jar',
420 deps = [':ewah']
421 )
422----
423
424This creates a symlink to the Buck targets direct against artifacts in
425another project's Maven target directory:
426
427----
428 buck-out/gen/lib/jgit/jgit.jar ->
429 /home/<user>/projects/jgit/org.eclipse.jgit/target/org.eclipse.jgit-3.3.0-SNAPSHOT.jar
430----
431
David Ostrovsky1a1b8b8a2014-10-23 22:37:58 +0200432After `buck clean` and `buck build lib/jgit:jgit` the symbolic link that was
433created the first time is lost due to Buck's caching mechanism. This means that
434when a new version of the local artifact is deployed (by running `mvn package`
435in the JGit project in the example above), Buck is not aware of it, because it
436still has a stale version of it in its cache.
437
438To solve this problem and re-create the symbolic link, you don't need to wipe out
439the entire Buck cache. Just rebuilding the target with the `--no-cache` option
440does the job:
441
442----
443 buck clean
444 buck build --no-cache lib/jgit:jgit
445----
446
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800447== Building against artifacts from custom Maven repositories
David Ostrovsky2536d062013-11-14 00:35:07 +0100448
449To build against custom Maven repositories, two modes of operations are
450supported: with rewrite in local.properties and without.
451
452Without rewrite the URL of custom Maven repository can be directly passed
453to the maven_jar() function:
454
455[source,python]
456----
457 GERRIT_FORGE = 'http://gerritforge.com/snapshot'
458
459 maven_jar(
460 name = 'gitblit',
461 id = 'com.gitblit:gitblit:1.4.0',
462 sha1 = '1b130dbf5578ace37507430a4a523f6594bf34fa',
463 license = 'Apache2.0',
464 repository = GERRIT_FORGE,
465 )
466----
467
468When the custom URL has to be rewritten, then the same logic as with Gerrit
469known Maven repository is used: Repo name must be defined that matches an entry
470in local.properties file:
471
472----
473 download.GERRIT_FORGE = http://my.company.mirror/gerrit-forge
474----
475
476And corresponding BUCK excerpt:
477
478[source,python]
479----
480 GERRIT_FORGE = 'GERRIT_FORGE:'
481
482 maven_jar(
483 name = 'gitblit',
484 id = 'com.gitblit:gitblit:1.4.0',
485 sha1 = '1b130dbf5578ace37507430a4a523f6594bf34fa',
486 license = 'Apache2.0',
487 repository = GERRIT_FORGE,
488 )
489----
490
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800491=== Caching Build Results
Shawn Pearce9e4e2432013-05-30 13:09:29 -0700492
493Build results can be locally cached, saving rebuild time when
494switching between Git branches. Buck's documentation covers
495caching in link:http://facebook.github.io/buck/concept/buckconfig.html[buckconfig].
496The trivial case using a local directory is:
497
498----
499 cat >.buckconfig.local <<EOF
500 [cache]
501 mode = dir
502 dir = buck-cache
503 EOF
504----
505
David Pursehouse6c3fd802014-10-24 13:50:44 +0900506[[clean-cache]]
507=== Cleaning The Buck Cache
508
509The cache for the Gerrit Code Review project is located in
510`~/.gerritcodereview/buck-cache/cache`.
511
512The Buck cache should never need to be manually deleted. If you find yourself
513deleting the Buck cache regularly, then it is likely that there is something
514wrong with your environment or your workflow.
515
516If you really do need to clean the cache manually, then:
517
518----
519 rm -rf ~/.gerritcodereview/buck-cache/cache
520----
521
522Note that the root `buck-cache` folder should not be deleted as this is where
523downloaded artifacts are stored.
524
Edwin Kempin9a8b1dc2013-09-16 09:08:34 +0200525[[buck-daemon]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800526=== Using Buck daemon
David Ostrovskyd5ae8d32013-09-15 20:10:17 +0200527
David Pursehouseb99db5c2013-09-26 11:34:42 +0900528Buck ships with a daemon command `buckd`, which uses the
David Ostrovskyd5ae8d32013-09-15 20:10:17 +0200529link:https://github.com/martylamb/nailgun[Nailgun] protocol for running
530Java programs from the command line without incurring the JVM startup
David Pursehouseb99db5c2013-09-26 11:34:42 +0900531overhead.
532
533Using a Buck daemon can save significant amounts of time as it avoids the
534overhead of starting a Java virtual machine, loading the buck class files
535and parsing the build files for each command.
536
537It is safe to run several buck daemons started from different project
538directories and they will not interfere with each other. Buck's documentation
539covers daemon in http://facebook.github.io/buck/command/buckd.html[buckd].
540
David Ostrovsky26e3be62014-05-23 08:34:07 +0200541To use `buckd` the additional
542link:https://facebook.github.io/watchman[watchman] program must be installed.
543
David Ostrovsky37175422014-09-22 09:55:40 +0200544To disable `buckd`, the environment variable `NO_BUCKD` must be set. It's not
545recommended to put it in the shell config, as it can be forgotten about it and
546then assumed Buck was working as it should when it should be using buckd.
547Prepend the variable to Buck invocation instead:
548
549----
David Pursehouse8d4d3162014-10-24 13:57:06 +0900550 NO_BUCKD=1 buck build gerrit
David Ostrovsky37175422014-09-22 09:55:40 +0200551----
552
David Ostrovsky26e3be62014-05-23 08:34:07 +0200553[[watchman]]
554=== Installing watchman
555
556Watchman is used internally by Buck to monitor directory trees and is needed
557for buck daemon to work properly. Because buckd is activated by default in the
558latest version of Buck, it searches for the watchman executable in the
559path and issues a warning when it is not found and kills buckd.
560
561To prepare watchman installation on Linux:
David Ostrovskyd5ae8d32013-09-15 20:10:17 +0200562
563----
David Ostrovsky26e3be62014-05-23 08:34:07 +0200564 git clone https://github.com/facebook/watchman.git
565 cd watchman
566 ./autogen.sh
David Ostrovskyd5ae8d32013-09-15 20:10:17 +0200567----
568
David Ostrovsky26e3be62014-05-23 08:34:07 +0200569To install it in user home directory (without root privileges):
570
571----
572 ./configure --prefix $HOME/watchman
573 make install
574----
575
576To install it system wide:
577
578----
579 ./configure
580 make
581 sudo make install
582----
583
584Put $HOME/watchman/bin/watchman in path or link to $HOME/bin/watchman.
585
586To install watchman on OS X:
587
588----
589 brew install --HEAD watchman
590----
591
592See the original documentation for more information:
593link:https://facebook.github.io/watchman/docs/install.html[Watchman
594installation].
595
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800596=== Override Buck's settings
David Ostrovskyefaff302013-09-20 22:36:14 +0200597
Shawn Pearce4e1a8bc2013-11-28 18:38:30 -0800598Additional JVM args for Buck can be set in `.buckjavaargs` in the
599project root directory. For example to override Buck's default 1GB
600heap size:
David Ostrovskyefaff302013-09-20 22:36:14 +0200601
602----
Shawn Pearce4e1a8bc2013-11-28 18:38:30 -0800603 cat > .buckjavaargs <<EOF
604 -XX:MaxPermSize=512m -Xms8000m -Xmx16000m
David Ostrovskyefaff302013-09-20 22:36:14 +0200605 EOF
606----
607
David Ostrovskyfe2934e2014-04-22 00:36:12 +0200608== Rerun unit tests
David Ostrovskya4ea92e72014-03-25 06:42:33 -0700609
David Pursehouse56f60a42014-07-10 11:20:33 +0900610Test execution results are cached by Buck. If a test that was already run
611needs to be repeated, the unit test cache for that test must be removed first:
David Ostrovskya4ea92e72014-03-25 06:42:33 -0700612
613----
Dave Borowitzb800a612015-04-11 14:27:11 -0400614 rm -rf buck-out/bin/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/group/.AddRemoveGroupMembersIT/
David Ostrovskya4ea92e72014-03-25 06:42:33 -0700615----
616
David Pursehouse56f60a42014-07-10 11:20:33 +0900617After clearing the cache, the test can be run again:
David Ostrovskya4ea92e72014-03-25 06:42:33 -0700618
619----
Dave Borowitzb800a612015-04-11 14:27:11 -0400620 buck test //gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/group:AddRemoveGroupMembersIT
621 TESTING //gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/group:AddRemoveGroupMembersIT
David Ostrovskya4ea92e72014-03-25 06:42:33 -0700622 PASS 14,9s 8 Passed 0 Failed com.google.gerrit.acceptance.rest.group.AddRemoveGroupMembersIT
623 TESTS PASSED
624----
625
David Pursehouse56f60a42014-07-10 11:20:33 +0900626An alternative approach is to use Buck's `--filters` (`-f`) option:
David Ostrovskya4ea92e72014-03-25 06:42:33 -0700627
628----
David Pursehouse56f60a42014-07-10 11:20:33 +0900629 buck test -f 'com.google.gerrit.acceptance.rest.change.SubmitByMergeAlwaysIT'
David Ostrovskya4ea92e72014-03-25 06:42:33 -0700630 TESTING SELECTED TESTS
631 PASS 14,5s 6 Passed 0 Failed com.google.gerrit.acceptance.rest.change.SubmitByMergeAlwaysIT
632 TESTS PASSED
633----
634
David Pursehouse56f60a42014-07-10 11:20:33 +0900635When this option is used, the cache is disabled per design and doesn't need to
636be explicitly deleted.
637
638Note that when this option is used, the whole unit test cache is dropped, so
David Ostrovsky074859e2014-04-19 22:52:47 +0200639repeating the
640
641----
David Pursehouse56f60a42014-07-10 11:20:33 +0900642buck test
David Ostrovsky074859e2014-04-19 22:52:47 +0200643----
644
David Pursehouse56f60a42014-07-10 11:20:33 +0900645causes all tests to be executed again.
646
647To run tests without using cached results at all, use the `--no-results-cache`
648option:
649
650----
651buck test --no-results-cache
652----
David Ostrovskya4ea92e72014-03-25 06:42:33 -0700653
David Ostrovsky44c7e612015-06-16 08:58:48 +0200654== Known issues and bugs
655
656=== Symbolic links and `watchman`
657
658`Buck` with activated `Watchman` has currently a
659[known bug](https://github.com/facebook/buck/issues/341) related to
660symbolic links. The symbolic links are used very often with external
661plugins, that are linked per symbolic link to the plugins directory.
662With this use case Buck is failing to rebuild the plugin artefact
663after it was built. All attempts to convince Buck to rebuild will fail.
664The only known way to recover is to weep out `buck-out` directory. The
665better workaround is to avoid using Watchman in this specific use case.
666Watchman can either be de-installed or disabled. See
667link:#buck-daemon[Using Buck daemon] section above how to temporarily
668disable `buckd`.
669
David Pursehouse226eaf32014-12-18 17:49:28 +0900670== Troubleshooting Buck
671
672In some cases problems with Buck itself need to be investigated. See for example
673link:https://gerrit-review.googlesource.com/62411[this attempt to upgrade Buck]
674and link:https://github.com/facebook/buck/pull/227[the fix that was needed] to
675make the update possible.
676
677To build Gerrit with a custom version of Buck, the following steps are necessary:
678
6791. In the Buck git apply any necessary changes from pull requests
6802. Compile Buck with `ant`
6813. In the root of the Gerrit project create a `.nobuckcheck` file to prevent Buck
682from updating itself
6834. Replace the sha1 in Gerrit's `.buckversion` file with the required version from
684the custom Buck build
6855. Build Gerrit as usual
686
David Pursehoused0525a72013-05-09 17:49:34 +0100687GERRIT
688------
689Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700690
691SEARCHBOX
692---------