blob: 0acf04ad86d9adb7d6e9b22ff79e719fcc5b27d3 [file] [log] [blame]
David Pursehoused0525a72013-05-09 17:49:34 +01001Gerrit Code Review - Building with Buck
2=======================================
3
4
5Installation
6------------
7
8There 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
10OS are supported.
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
17 ant
18----
19
David Pursehouse5c42b8c2013-05-17 13:25:47 +010020Make sure you have a `bin/` directory in your home directory and that
21it is included in your path:
David Pursehoused0525a72013-05-09 17:49:34 +010022
23----
David Pursehouse64c16442013-05-14 10:49:03 +090024 mkdir ~/bin
25 PATH=~/bin:$PATH
David Pursehoused0525a72013-05-09 17:49:34 +010026----
27
David Pursehouse5c42b8c2013-05-17 13:25:47 +010028Add a symbolic link in `~/bin` to the buck executable:
David Pursehoused0525a72013-05-09 17:49:34 +010029
30----
David Pursehouse64c16442013-05-14 10:49:03 +090031 ln -s `pwd`/bin/buck ~/bin/
32----
33
David Pursehouse5c42b8c2013-05-17 13:25:47 +010034Verify that `buck` is accessible:
David Pursehouse64c16442013-05-14 10:49:03 +090035
36----
37 which buck
David Pursehoused0525a72013-05-09 17:49:34 +010038----
39
Edwin Kempin9a8b1dc2013-09-16 09:08:34 +020040If you plan to use the link:#buck-daemon[Buck daemon] add a symbolic
41link in `~/bin` to the buckd executable:
42
43----
44 ln -s `pwd`/bin/buckd ~/bin/
45----
46
David Pursehoused0525a72013-05-09 17:49:34 +010047
David Pursehouse5861a9a2013-05-15 10:25:19 +090048[[eclipse]]
49Eclipse Integration
50-------------------
David Pursehoused0525a72013-05-09 17:49:34 +010051
52
53Generating the Eclipse Project
54~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
55
Shawn Pearcea7a3ee12013-09-20 10:42:37 -070056Create the Eclipse project:
David Pursehoused0525a72013-05-09 17:49:34 +010057
58----
Shawn Pearcea7a3ee12013-09-20 10:42:37 -070059 tools/eclipse/project.py
David Pursehoused0525a72013-05-09 17:49:34 +010060----
61
62In Eclipse, choose 'Import existing project' and select the `gerrit` project
Edwin Kempin0d687ff2013-06-14 09:41:07 +020063from the current working directory.
David Pursehoused0525a72013-05-09 17:49:34 +010064
65Expand the `gerrit` project, right-click on the `buck-out` folder, select
66'Properties', and then under 'Attributes' check 'Derived'.
67
Shawn Pearcea7a3ee12013-09-20 10:42:37 -070068Note that if you make any changes in the project configuration
69that get saved to the `.project` file, for example adding Resource
70Filters on a folder, they will be overwritten the next time you run
71`tools/eclipse/project.py`.
David Pursehouse38ba8802013-05-17 13:42:03 +010072
David Pursehouseb46cf492013-05-14 09:41:30 +090073
David Pursehouse1d0435e2013-05-14 10:26:51 +090074Refreshing the Classpath
75~~~~~~~~~~~~~~~~~~~~~~~~
David Pursehoused0525a72013-05-09 17:49:34 +010076
Shawn Pearcea7a3ee12013-09-20 10:42:37 -070077If an updated classpath is needed, the Eclipse project can be
78refreshed and missing dependency JARs can be downloaded:
David Pursehoused0525a72013-05-09 17:49:34 +010079
80----
Shawn Pearcea7a3ee12013-09-20 10:42:37 -070081 tools/eclipse/project.py
David Pursehoused0525a72013-05-09 17:49:34 +010082----
83
84
Shawn Pearce7b553262013-05-13 21:25:13 -070085Attaching Sources
86~~~~~~~~~~~~~~~~~
87
88To save time and bandwidth source JARs are only downloaded by the buck
89build where necessary to compile Java source into JavaScript using the
90GWT compiler. Additional sources may be obtained, allowing Eclipse to
91show documentation or dive into the implementation of a library JAR:
92
93----
Shawn Pearcea7a3ee12013-09-20 10:42:37 -070094 tools/eclipse/project.py --src
Shawn Pearce7b553262013-05-13 21:25:13 -070095----
96
97
David Pursehouse6de7ee22013-05-20 11:08:51 +090098[[build]]
David Pursehoused0525a72013-05-09 17:49:34 +010099Building on the Command Line
100----------------------------
101
102
103Gerrit Development WAR File
104~~~~~~~~~~~~~~~~~~~~~~~~~~~
105
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
119Extension and Plugin API JAR Files
120~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
121
122To build the extension and plugin API JAR files:
123
124----
125 buck build api
126----
127
128The output JAR files will be placed in:
129
130----
131 buck-out/gen/{extension,plugin}-api.jar
132----
133
David Ostrovsky6e6a9672013-05-30 01:10:12 +0200134Install {extension,plugin}-api to the local maven repository:
135
136----
137 buck build api_install
138----
139
140Deploy {extension,plugin}-api to the remote maven repository
141
142----
143 buck build api_deploy
144----
145
146The 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 Pursehouseb46cf492013-05-14 09:41:30 +0900149
David Pursehouse0bc51db2013-05-14 12:46:49 +0900150Plugins
151~~~~~~~
152
153To build all core plugins:
154
155----
156 buck build plugins:core
157----
158
159The output JAR files for individual plugins will be placed in:
160
161----
162 buck-out/gen/plugins/<name>/<name>.jar
163----
164
165The JAR files will also be packaged in:
166
167----
168 buck-out/gen/plugins/core.zip
169----
170
171To build a specific plugin:
172
173----
174 buck build plugins/<name>
175----
176
177The output JAR file will be be placed in:
178
179----
180 buck-out/gen/plugins/<name>/<name>.jar
181----
182
183Note that when building an individual plugin, the `core.zip` package
184is not regenerated.
185
David Pursehouse90a9c102013-09-06 18:42:10 +0900186
187[[documentation]]
188Documentation
189~~~~~~~~~~~~~
190
191To build the documentation:
192
193----
194 buck build docs
195----
196
197The generated html files will be placed in:
198
199----
200 buck-out/gen/Documentation
201----
202
203The html files will also be bundled into `html.zip` in the same location.
204
205
David Ostrovsky811e6032013-09-06 08:35:45 +0200206[[release]]
207Gerrit Release WAR File
208~~~~~~~~~~~~~~~~~~~~~~~
209
210To build the release of the Gerrit web application, including documentation and
211all core plugins:
212
213----
214 buck build release
215----
216
217The output release WAR will be placed in:
218
219----
220 buck-out/gen/release.war
221----
David Pursehouse0bc51db2013-05-14 12:46:49 +0900222
David Pursehouse5861a9a2013-05-15 10:25:19 +0900223[[tests]]
David Pursehoused0525a72013-05-09 17:49:34 +0100224Running Unit Tests
225------------------
226
227To run all tests including acceptance tests:
228
229----
230 buck test --all
231----
232
233To exclude slow tests:
234
235----
Shawn Pearce11d27c82013-07-24 08:09:31 -0700236 buck test --all --exclude slow
David Pursehoused0525a72013-05-09 17:49:34 +0100237----
238
Edwin Kempin674078a2013-08-20 11:37:14 +0200239To 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 Pursehoused0525a72013-05-09 17:49:34 +0100246
David Pursehoused0525a72013-05-09 17:49:34 +0100247Dependencies
248------------
249
250Dependency JARs are normally downloaded automatically, but Buck can inspect
251its graph and download any missing JAR files. This is useful to enable
Shawn Pearcea7a3ee12013-09-20 10:42:37 -0700252subsequent builds to run without network access:
David Pursehoused0525a72013-05-09 17:49:34 +0100253
254----
Shawn Pearcea7a3ee12013-09-20 10:42:37 -0700255 tools/download_all.py
David Pursehoused0525a72013-05-09 17:49:34 +0100256----
257
David Pursehouseb46cf492013-05-14 09:41:30 +0900258When downloading from behind a proxy (which is common in some corporate
259environments), it might be necessary to explicitly specify the proxy that
260is then used by `curl`:
261
262----
263 export http_proxy=http://<proxy_user_id>:<proxy_password>@<proxy_server>:<proxy_port>
264----
265
Shawn Pearce1b89f852013-05-13 20:26:34 -0700266Redirection to local mirrors of Maven Central and the Gerrit storage
267bucket 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 Pursehouse6fb2c4d2013-05-16 16:51:46 +0900275The `local.properties` file may be placed in the root of the gerrit repository
276being built, or in `~/.gerritcodereview/`. The file in the root of the gerrit
277repository has precedence.
278
David Ostrovskyee9f9922013-08-15 00:21:04 +0200279Building against unpublished Maven JARs
280---------------------------------------
281
282To build against unpublished Maven JARs, like gwtorm or PrologCafe, the custom
283JARs must be installed in the local Maven repository (mvn clean install) and
284maven_jar() must be updated to point to the MAVEN_LOCAL Maven repository for
285that artifact:
286
287----
288 maven_jar(
289 name = 'gwtorm',
290 id = 'gwtorm:gwtorm:42',
David Ostrovskyee9f9922013-08-15 00:21:04 +0200291 license = 'Apache2.0',
292 repository = MAVEN_LOCAL,
293 )
294----
295
Shawn Pearce9e4e2432013-05-30 13:09:29 -0700296Caching Build Results
297~~~~~~~~~~~~~~~~~~~~~
298
299Build results can be locally cached, saving rebuild time when
300switching between Git branches. Buck's documentation covers
301caching in link:http://facebook.github.io/buck/concept/buckconfig.html[buckconfig].
302The trivial case using a local directory is:
303
304----
305 cat >.buckconfig.local <<EOF
306 [cache]
307 mode = dir
308 dir = buck-cache
309 EOF
310----
311
Edwin Kempin9a8b1dc2013-09-16 09:08:34 +0200312[[buck-daemon]]
David Ostrovskyd5ae8d32013-09-15 20:10:17 +0200313Using Buck daemon
314~~~~~~~~~~~~~~~~~
315
316Buck ships with daemon command `buckd`, which uses
317link:https://github.com/martylamb/nailgun[Nailgun] protocol for running
318Java programs from the command line without incurring the JVM startup
319overhead. Using a Buck daemon can save significant amounts of time as it
320avoids the overhead of starting a Java virtual machine, loading the buck class
321files and parsing the build files for each command. It is safe to run several
322buck daemons started from different project directories and they will not
323interfere with each other. Buck's documentation covers daemon in
324http://facebook.github.io/buck/command/buckd.html[buckd]. The trivial case is
325to run `buckd` from the project's root directory and use `buck` as usually:
326
327----
328$>buckd
329$>buck build gerrit
330Using buckd.
331[-] PARSING BUILD FILES...FINISHED 0.6s
332[-] BUILDING...FINISHED 0.2s
333----
334
David Pursehoused0525a72013-05-09 17:49:34 +0100335GERRIT
336------
337Part of link:index.html[Gerrit Code Review]