Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 1 | = Gerrit Code Review - Building with Buck |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 2 | |
| 3 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 4 | == Installation |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 5 | |
| 6 | 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] | 7 | built and installed. Apache Ant is required. Currently only Linux and Mac |
David Ostrovsky | e44706a | 2014-06-13 16:28:30 +0200 | [diff] [blame] | 8 | OS are supported. Buck requires Python version 2.7 to be installed. |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 9 | |
| 10 | Clone the git and build it: |
| 11 | |
| 12 | ---- |
| 13 | git clone https://gerrit.googlesource.com/buck |
| 14 | cd buck |
| 15 | ant |
| 16 | ---- |
| 17 | |
David Pursehouse | e9803ab | 2014-03-12 14:15:10 +0900 | [diff] [blame] | 18 | If you don't have a `bin/` directory in your home directory, create one: |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 19 | |
| 20 | ---- |
David Pursehouse | 64c1644 | 2013-05-14 10:49:03 +0900 | [diff] [blame] | 21 | mkdir ~/bin |
David Pursehouse | e9803ab | 2014-03-12 14:15:10 +0900 | [diff] [blame] | 22 | ---- |
| 23 | |
| 24 | Add the `~/bin` folder to the path: |
| 25 | |
| 26 | ---- |
David Pursehouse | 64c1644 | 2013-05-14 10:49:03 +0900 | [diff] [blame] | 27 | PATH=~/bin:$PATH |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 28 | ---- |
| 29 | |
David Pursehouse | e9803ab | 2014-03-12 14:15:10 +0900 | [diff] [blame] | 30 | Note that the buck executable needs to be available in all shell sessions, |
| 31 | so also make sure it is appended to the path globally. |
| 32 | |
David Pursehouse | 5c42b8c | 2013-05-17 13:25:47 +0100 | [diff] [blame] | 33 | Add a symbolic link in `~/bin` to the buck executable: |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 34 | |
| 35 | ---- |
David Pursehouse | 64c1644 | 2013-05-14 10:49:03 +0900 | [diff] [blame] | 36 | ln -s `pwd`/bin/buck ~/bin/ |
| 37 | ---- |
| 38 | |
David Pursehouse | 5c42b8c | 2013-05-17 13:25:47 +0100 | [diff] [blame] | 39 | Verify that `buck` is accessible: |
David Pursehouse | 64c1644 | 2013-05-14 10:49:03 +0900 | [diff] [blame] | 40 | |
| 41 | ---- |
| 42 | which buck |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 43 | ---- |
| 44 | |
David Pursehouse | be28499 | 2013-09-26 14:43:33 +0900 | [diff] [blame] | 45 | To enable autocompletion of buck commands, install the autocompletion |
| 46 | script from `./scripts/bash_completion` in the buck project. Refer to |
| 47 | the script's header comments for installation instructions. |
| 48 | |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 49 | |
David Pursehouse | 5861a9a | 2013-05-15 10:25:19 +0900 | [diff] [blame] | 50 | [[eclipse]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 51 | == Eclipse Integration |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 52 | |
| 53 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 54 | === Generating the Eclipse Project |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 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 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 74 | === Refreshing the Classpath |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 75 | |
Shawn Pearce | a7a3ee1 | 2013-09-20 10:42:37 -0700 | [diff] [blame] | 76 | If an updated classpath is needed, the Eclipse project can be |
| 77 | refreshed and missing dependency JARs can be downloaded: |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 78 | |
| 79 | ---- |
Shawn Pearce | a7a3ee1 | 2013-09-20 10:42:37 -0700 | [diff] [blame] | 80 | tools/eclipse/project.py |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 81 | ---- |
| 82 | |
| 83 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 84 | === Attaching Sources |
Shawn Pearce | 7b55326 | 2013-05-13 21:25:13 -0700 | [diff] [blame] | 85 | |
| 86 | To save time and bandwidth source JARs are only downloaded by the buck |
| 87 | build where necessary to compile Java source into JavaScript using the |
| 88 | GWT compiler. Additional sources may be obtained, allowing Eclipse to |
| 89 | show documentation or dive into the implementation of a library JAR: |
| 90 | |
| 91 | ---- |
Shawn Pearce | a7a3ee1 | 2013-09-20 10:42:37 -0700 | [diff] [blame] | 92 | tools/eclipse/project.py --src |
Shawn Pearce | 7b55326 | 2013-05-13 21:25:13 -0700 | [diff] [blame] | 93 | ---- |
| 94 | |
| 95 | |
David Pursehouse | 6de7ee2 | 2013-05-20 11:08:51 +0900 | [diff] [blame] | 96 | [[build]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 97 | == Building on the Command Line |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 98 | |
| 99 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 100 | === Gerrit Development WAR File |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 101 | |
| 102 | To build the Gerrit web application: |
| 103 | |
| 104 | ---- |
| 105 | buck build gerrit |
| 106 | ---- |
| 107 | |
| 108 | The output executable WAR will be placed in: |
| 109 | |
| 110 | ---- |
| 111 | buck-out/gen/gerrit.war |
| 112 | ---- |
| 113 | |
| 114 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 115 | === Extension and Plugin API JAR Files |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 116 | |
David Ostrovsky | e5487a0 | 2013-11-25 00:00:13 +0100 | [diff] [blame] | 117 | To build the extension, plugin and GWT API JAR files: |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 118 | |
| 119 | ---- |
| 120 | buck build api |
| 121 | ---- |
| 122 | |
David Ostrovsky | e5487a0 | 2013-11-25 00:00:13 +0100 | [diff] [blame] | 123 | Java binaries, Java sources and Java docs are generated into corresponding |
David Pursehouse | 43dc748 | 2013-12-13 14:54:42 +0900 | [diff] [blame] | 124 | project directories in `buck-out/gen`, here as example for plugin API: |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 125 | |
| 126 | ---- |
David Ostrovsky | e5487a0 | 2013-11-25 00:00:13 +0100 | [diff] [blame] | 127 | buck-out/gen/gerrit-plugin-api/plugin-api.jar |
| 128 | buck-out/gen/gerrit-plugin-api/plugin-api-src.jar |
| 129 | buck-out/gen/gerrit-plugin-api/plugin-api-javadoc.jar |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 130 | ---- |
| 131 | |
David Ostrovsky | 358a458 | 2014-05-13 23:55:04 +0200 | [diff] [blame] | 132 | Install {extension,plugin,gwt}-api to the local maven repository: |
David Ostrovsky | 6e6a967 | 2013-05-30 01:10:12 +0200 | [diff] [blame] | 133 | |
| 134 | ---- |
| 135 | buck build api_install |
| 136 | ---- |
| 137 | |
David Ostrovsky | 358a458 | 2014-05-13 23:55:04 +0200 | [diff] [blame] | 138 | Install gerrit.war to the local maven repository: |
| 139 | |
| 140 | ---- |
| 141 | buck build war_install |
| 142 | ---- |
| 143 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 144 | === Plugins |
David Pursehouse | 0bc51db | 2013-05-14 12:46:49 +0900 | [diff] [blame] | 145 | |
| 146 | To build all core plugins: |
| 147 | |
| 148 | ---- |
| 149 | buck build plugins:core |
| 150 | ---- |
| 151 | |
| 152 | The output JAR files for individual plugins will be placed in: |
| 153 | |
| 154 | ---- |
| 155 | buck-out/gen/plugins/<name>/<name>.jar |
| 156 | ---- |
| 157 | |
| 158 | The JAR files will also be packaged in: |
| 159 | |
| 160 | ---- |
| 161 | buck-out/gen/plugins/core.zip |
| 162 | ---- |
| 163 | |
| 164 | To build a specific plugin: |
| 165 | |
| 166 | ---- |
Shawn Pearce | 6586c20 | 2013-11-09 08:54:48 -0800 | [diff] [blame] | 167 | buck build plugins/<name>:<name> |
David Pursehouse | 0bc51db | 2013-05-14 12:46:49 +0900 | [diff] [blame] | 168 | ---- |
| 169 | |
| 170 | The output JAR file will be be placed in: |
| 171 | |
| 172 | ---- |
| 173 | buck-out/gen/plugins/<name>/<name>.jar |
| 174 | ---- |
| 175 | |
| 176 | Note that when building an individual plugin, the `core.zip` package |
| 177 | is not regenerated. |
| 178 | |
Shawn Pearce | 6586c20 | 2013-11-09 08:54:48 -0800 | [diff] [blame] | 179 | Additional plugins with BUCK files can be added to the build |
| 180 | environment by cloning the source repository into the plugins |
| 181 | subdirectory: |
| 182 | |
| 183 | ---- |
| 184 | git clone https://gerrit.googlesource.com/plugins/<name> plugins/<name> |
| 185 | echo /plugins/<name> >>.git/info/exclude |
| 186 | ---- |
| 187 | |
| 188 | Additional plugin sources will be automatically added to Eclipse the |
| 189 | next time project.py is run: |
| 190 | |
| 191 | ---- |
| 192 | tools/eclipse/project.py |
| 193 | ---- |
| 194 | |
David Pursehouse | 90a9c10 | 2013-09-06 18:42:10 +0900 | [diff] [blame] | 195 | |
| 196 | [[documentation]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 197 | === Documentation |
David Pursehouse | 90a9c10 | 2013-09-06 18:42:10 +0900 | [diff] [blame] | 198 | |
David Pursehouse | c08d03e | 2013-12-10 18:16:10 +0900 | [diff] [blame] | 199 | To build only the documentation: |
David Pursehouse | 90a9c10 | 2013-09-06 18:42:10 +0900 | [diff] [blame] | 200 | |
| 201 | ---- |
| 202 | buck build docs |
| 203 | ---- |
| 204 | |
| 205 | The generated html files will be placed in: |
| 206 | |
| 207 | ---- |
David Ostrovsky | 7cd233e | 2013-09-26 07:21:31 +0200 | [diff] [blame] | 208 | buck-out/gen/Documentation/html__tmp/Documentation |
David Pursehouse | 90a9c10 | 2013-09-06 18:42:10 +0900 | [diff] [blame] | 209 | ---- |
| 210 | |
David Ostrovsky | 7cd233e | 2013-09-26 07:21:31 +0200 | [diff] [blame] | 211 | The html files will also be bundled into `html.zip` in this location: |
David Pursehouse | 90a9c10 | 2013-09-06 18:42:10 +0900 | [diff] [blame] | 212 | |
David Ostrovsky | 7cd233e | 2013-09-26 07:21:31 +0200 | [diff] [blame] | 213 | ---- |
| 214 | buck-out/gen/Documentation/html.zip |
| 215 | ---- |
David Pursehouse | 90a9c10 | 2013-09-06 18:42:10 +0900 | [diff] [blame] | 216 | |
David Pursehouse | c08d03e | 2013-12-10 18:16:10 +0900 | [diff] [blame] | 217 | To build the executable WAR with the documentation included: |
| 218 | |
| 219 | ---- |
| 220 | buck build withdocs |
| 221 | ---- |
| 222 | |
| 223 | The WAR file will be placed in: |
| 224 | |
| 225 | ---- |
| 226 | buck-out/gen/withdocs.war |
| 227 | ---- |
| 228 | |
David Ostrovsky | 811e603 | 2013-09-06 08:35:45 +0200 | [diff] [blame] | 229 | [[release]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 230 | === Gerrit Release WAR File |
David Ostrovsky | 811e603 | 2013-09-06 08:35:45 +0200 | [diff] [blame] | 231 | |
| 232 | To build the release of the Gerrit web application, including documentation and |
| 233 | all core plugins: |
| 234 | |
| 235 | ---- |
| 236 | buck build release |
| 237 | ---- |
| 238 | |
| 239 | The output release WAR will be placed in: |
| 240 | |
| 241 | ---- |
| 242 | buck-out/gen/release.war |
| 243 | ---- |
David Pursehouse | 0bc51db | 2013-05-14 12:46:49 +0900 | [diff] [blame] | 244 | |
David Ostrovsky | e64e30d | 2014-03-25 06:25:56 -0700 | [diff] [blame] | 245 | [[all]] |
| 246 | === Combined build target |
| 247 | |
| 248 | To build release and api targets, a combined build target is provided: |
| 249 | |
| 250 | ---- |
| 251 | buck build all |
| 252 | ---- |
| 253 | |
David Pursehouse | 5861a9a | 2013-05-15 10:25:19 +0900 | [diff] [blame] | 254 | [[tests]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 255 | == Running Unit Tests |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 256 | |
| 257 | To run all tests including acceptance tests: |
| 258 | |
| 259 | ---- |
David Ostrovsky | 530a4c3 | 2014-06-25 00:36:59 +0200 | [diff] [blame] | 260 | buck test |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 261 | ---- |
| 262 | |
| 263 | To exclude slow tests: |
| 264 | |
| 265 | ---- |
Shawn Pearce | 11d27c8 | 2013-07-24 08:09:31 -0700 | [diff] [blame] | 266 | buck test --all --exclude slow |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 267 | ---- |
| 268 | |
David Ostrovsky | c4e0ac6 | 2014-04-21 18:25:18 +0200 | [diff] [blame] | 269 | To include a specific group of acceptance tests: |
| 270 | |
| 271 | ---- |
| 272 | buck test --all --include api |
| 273 | ---- |
| 274 | |
| 275 | The following groups of tests are currently supported: |
| 276 | |
| 277 | * api |
| 278 | * git |
| 279 | * pgm |
| 280 | * rest |
| 281 | * server |
| 282 | * ssh |
| 283 | |
Edwin Kempin | 674078a | 2013-08-20 11:37:14 +0200 | [diff] [blame] | 284 | To run a specific test, e.g. the acceptance test |
| 285 | `com.google.gerrit.acceptance.git.HttpPushForReviewIT`: |
| 286 | |
| 287 | ---- |
| 288 | buck test //gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/git:HttpPushForReviewIT |
| 289 | ---- |
| 290 | |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 291 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 292 | == Dependencies |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 293 | |
| 294 | Dependency JARs are normally downloaded automatically, but Buck can inspect |
| 295 | 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] | 296 | subsequent builds to run without network access: |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 297 | |
| 298 | ---- |
Shawn Pearce | a7a3ee1 | 2013-09-20 10:42:37 -0700 | [diff] [blame] | 299 | tools/download_all.py |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 300 | ---- |
| 301 | |
David Pursehouse | b46cf49 | 2013-05-14 09:41:30 +0900 | [diff] [blame] | 302 | When downloading from behind a proxy (which is common in some corporate |
| 303 | environments), it might be necessary to explicitly specify the proxy that |
| 304 | is then used by `curl`: |
| 305 | |
| 306 | ---- |
| 307 | export http_proxy=http://<proxy_user_id>:<proxy_password>@<proxy_server>:<proxy_port> |
| 308 | ---- |
| 309 | |
Shawn Pearce | 1b89f85 | 2013-05-13 20:26:34 -0700 | [diff] [blame] | 310 | Redirection to local mirrors of Maven Central and the Gerrit storage |
| 311 | bucket is supported by defining specific properties in |
| 312 | `local.properties`, a file that is not tracked by Git: |
| 313 | |
| 314 | ---- |
| 315 | echo download.GERRIT = http://nexus.my-company.com/ >>local.properties |
| 316 | echo download.MAVEN_CENTRAL = http://nexus.my-company.com/ >>local.properties |
| 317 | ---- |
| 318 | |
David Pursehouse | 6fb2c4d | 2013-05-16 16:51:46 +0900 | [diff] [blame] | 319 | The `local.properties` file may be placed in the root of the gerrit repository |
| 320 | being built, or in `~/.gerritcodereview/`. The file in the root of the gerrit |
| 321 | repository has precedence. |
| 322 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 323 | == Building against unpublished Maven JARs |
David Ostrovsky | ee9f992 | 2013-08-15 00:21:04 +0200 | [diff] [blame] | 324 | |
| 325 | To build against unpublished Maven JARs, like gwtorm or PrologCafe, the custom |
David Pursehouse | b99db5c | 2013-09-26 11:34:42 +0900 | [diff] [blame] | 326 | JARs must be installed in the local Maven repository (`mvn clean install`) and |
| 327 | `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] | 328 | that artifact: |
| 329 | |
David Pursehouse | b99db5c | 2013-09-26 11:34:42 +0900 | [diff] [blame] | 330 | [source,python] |
David Ostrovsky | ee9f992 | 2013-08-15 00:21:04 +0200 | [diff] [blame] | 331 | ---- |
| 332 | maven_jar( |
| 333 | name = 'gwtorm', |
| 334 | id = 'gwtorm:gwtorm:42', |
David Ostrovsky | ee9f992 | 2013-08-15 00:21:04 +0200 | [diff] [blame] | 335 | license = 'Apache2.0', |
| 336 | repository = MAVEN_LOCAL, |
| 337 | ) |
| 338 | ---- |
| 339 | |
David Ostrovsky | 07df959 | 2014-02-01 23:47:22 +0100 | [diff] [blame] | 340 | == Building against unpublished JARs, that change frequently |
| 341 | |
| 342 | If a dependent Gerrit library is undergoing active development it must be |
| 343 | recompiled and the change must be reflected in the Buck build process. For |
| 344 | example testing Gerrit against changed JGit snapshot version. After building |
| 345 | JGit library, the artifacts are created in local Maven build directory, e. g.: |
| 346 | |
| 347 | ---- |
| 348 | mvn package |
| 349 | /home/<user>/projects/jgit/org.eclipse.jgit/target/org.eclipse.jgit-3.3.0-SNAPSHOT.jar |
| 350 | /home/<user>/projects/jgit/org.eclipse.jgit/target/org.eclipse.jgit-3.3.0-SNAPSHOT-sources.jar |
| 351 | ---- |
| 352 | |
| 353 | If as usual, installation of the build artifacts takes place in local maven |
| 354 | repository, then the Buck build must fetch them from there with normal |
| 355 | `download_file.py` process. Disadvantage of this approach is that Buck cache |
| 356 | invalidation must occur to refresh the artifacts after next |
| 357 | change-compile-install round trip. |
| 358 | |
| 359 | To shorten that workflow and take the installation of the artifacts to the |
| 360 | local Maven repository and fetching it again from there out of the picture, |
| 361 | `local_jar()` method is used instead of `maven_jar()`: |
| 362 | |
| 363 | [source,python] |
| 364 | ---- |
| 365 | local_jar( |
| 366 | name = 'jgit', |
| 367 | jar = '/home/<user>/projects/jgit/org.eclipse.jgit/target/org.eclipse.jgit-3.3.0-SNAPSHOT.jar', |
| 368 | src = '/home/<user>/projects/jgit/org.eclipse.jgit/target/org.eclipse.jgit-3.3.0-SNAPSHOT-sources.jar', |
| 369 | deps = [':ewah'] |
| 370 | ) |
| 371 | ---- |
| 372 | |
| 373 | This creates a symlink to the Buck targets direct against artifacts in |
| 374 | another project's Maven target directory: |
| 375 | |
| 376 | ---- |
| 377 | buck-out/gen/lib/jgit/jgit.jar -> |
| 378 | /home/<user>/projects/jgit/org.eclipse.jgit/target/org.eclipse.jgit-3.3.0-SNAPSHOT.jar |
| 379 | ---- |
| 380 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 381 | == Building against artifacts from custom Maven repositories |
David Ostrovsky | 2536d06 | 2013-11-14 00:35:07 +0100 | [diff] [blame] | 382 | |
| 383 | To build against custom Maven repositories, two modes of operations are |
| 384 | supported: with rewrite in local.properties and without. |
| 385 | |
| 386 | Without rewrite the URL of custom Maven repository can be directly passed |
| 387 | to the maven_jar() function: |
| 388 | |
| 389 | [source,python] |
| 390 | ---- |
| 391 | GERRIT_FORGE = 'http://gerritforge.com/snapshot' |
| 392 | |
| 393 | maven_jar( |
| 394 | name = 'gitblit', |
| 395 | id = 'com.gitblit:gitblit:1.4.0', |
| 396 | sha1 = '1b130dbf5578ace37507430a4a523f6594bf34fa', |
| 397 | license = 'Apache2.0', |
| 398 | repository = GERRIT_FORGE, |
| 399 | ) |
| 400 | ---- |
| 401 | |
| 402 | When the custom URL has to be rewritten, then the same logic as with Gerrit |
| 403 | known Maven repository is used: Repo name must be defined that matches an entry |
| 404 | in local.properties file: |
| 405 | |
| 406 | ---- |
| 407 | download.GERRIT_FORGE = http://my.company.mirror/gerrit-forge |
| 408 | ---- |
| 409 | |
| 410 | And corresponding BUCK excerpt: |
| 411 | |
| 412 | [source,python] |
| 413 | ---- |
| 414 | GERRIT_FORGE = 'GERRIT_FORGE:' |
| 415 | |
| 416 | maven_jar( |
| 417 | name = 'gitblit', |
| 418 | id = 'com.gitblit:gitblit:1.4.0', |
| 419 | sha1 = '1b130dbf5578ace37507430a4a523f6594bf34fa', |
| 420 | license = 'Apache2.0', |
| 421 | repository = GERRIT_FORGE, |
| 422 | ) |
| 423 | ---- |
| 424 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 425 | === Caching Build Results |
Shawn Pearce | 9e4e243 | 2013-05-30 13:09:29 -0700 | [diff] [blame] | 426 | |
| 427 | Build results can be locally cached, saving rebuild time when |
| 428 | switching between Git branches. Buck's documentation covers |
| 429 | caching in link:http://facebook.github.io/buck/concept/buckconfig.html[buckconfig]. |
| 430 | The trivial case using a local directory is: |
| 431 | |
| 432 | ---- |
| 433 | cat >.buckconfig.local <<EOF |
| 434 | [cache] |
| 435 | mode = dir |
| 436 | dir = buck-cache |
| 437 | EOF |
| 438 | ---- |
| 439 | |
Edwin Kempin | 9a8b1dc | 2013-09-16 09:08:34 +0200 | [diff] [blame] | 440 | [[buck-daemon]] |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 441 | === Using Buck daemon |
David Ostrovsky | d5ae8d3 | 2013-09-15 20:10:17 +0200 | [diff] [blame] | 442 | |
David Pursehouse | b99db5c | 2013-09-26 11:34:42 +0900 | [diff] [blame] | 443 | Buck ships with a daemon command `buckd`, which uses the |
David Ostrovsky | d5ae8d3 | 2013-09-15 20:10:17 +0200 | [diff] [blame] | 444 | link:https://github.com/martylamb/nailgun[Nailgun] protocol for running |
| 445 | Java programs from the command line without incurring the JVM startup |
David Pursehouse | b99db5c | 2013-09-26 11:34:42 +0900 | [diff] [blame] | 446 | overhead. |
| 447 | |
| 448 | Using a Buck daemon can save significant amounts of time as it avoids the |
| 449 | overhead of starting a Java virtual machine, loading the buck class files |
| 450 | and parsing the build files for each command. |
| 451 | |
| 452 | It is safe to run several buck daemons started from different project |
| 453 | directories and they will not interfere with each other. Buck's documentation |
| 454 | covers daemon in http://facebook.github.io/buck/command/buckd.html[buckd]. |
| 455 | |
David Ostrovsky | 26e3be6 | 2014-05-23 08:34:07 +0200 | [diff] [blame] | 456 | To use `buckd` the additional |
| 457 | link:https://facebook.github.io/watchman[watchman] program must be installed. |
| 458 | |
| 459 | [[watchman]] |
| 460 | === Installing watchman |
| 461 | |
| 462 | Watchman is used internally by Buck to monitor directory trees and is needed |
| 463 | for buck daemon to work properly. Because buckd is activated by default in the |
| 464 | latest version of Buck, it searches for the watchman executable in the |
| 465 | path and issues a warning when it is not found and kills buckd. |
| 466 | |
| 467 | To prepare watchman installation on Linux: |
David Ostrovsky | d5ae8d3 | 2013-09-15 20:10:17 +0200 | [diff] [blame] | 468 | |
| 469 | ---- |
David Ostrovsky | 26e3be6 | 2014-05-23 08:34:07 +0200 | [diff] [blame] | 470 | git clone https://github.com/facebook/watchman.git |
| 471 | cd watchman |
| 472 | ./autogen.sh |
David Ostrovsky | d5ae8d3 | 2013-09-15 20:10:17 +0200 | [diff] [blame] | 473 | ---- |
| 474 | |
David Ostrovsky | 26e3be6 | 2014-05-23 08:34:07 +0200 | [diff] [blame] | 475 | To install it in user home directory (without root privileges): |
| 476 | |
| 477 | ---- |
| 478 | ./configure --prefix $HOME/watchman |
| 479 | make install |
| 480 | ---- |
| 481 | |
| 482 | To install it system wide: |
| 483 | |
| 484 | ---- |
| 485 | ./configure |
| 486 | make |
| 487 | sudo make install |
| 488 | ---- |
| 489 | |
| 490 | Put $HOME/watchman/bin/watchman in path or link to $HOME/bin/watchman. |
| 491 | |
| 492 | To install watchman on OS X: |
| 493 | |
| 494 | ---- |
| 495 | brew install --HEAD watchman |
| 496 | ---- |
| 497 | |
| 498 | See the original documentation for more information: |
| 499 | link:https://facebook.github.io/watchman/docs/install.html[Watchman |
| 500 | installation]. |
| 501 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 502 | === Override Buck's settings |
David Ostrovsky | efaff30 | 2013-09-20 22:36:14 +0200 | [diff] [blame] | 503 | |
Shawn Pearce | 4e1a8bc | 2013-11-28 18:38:30 -0800 | [diff] [blame] | 504 | Additional JVM args for Buck can be set in `.buckjavaargs` in the |
| 505 | project root directory. For example to override Buck's default 1GB |
| 506 | heap size: |
David Ostrovsky | efaff30 | 2013-09-20 22:36:14 +0200 | [diff] [blame] | 507 | |
| 508 | ---- |
Shawn Pearce | 4e1a8bc | 2013-11-28 18:38:30 -0800 | [diff] [blame] | 509 | cat > .buckjavaargs <<EOF |
| 510 | -XX:MaxPermSize=512m -Xms8000m -Xmx16000m |
David Ostrovsky | efaff30 | 2013-09-20 22:36:14 +0200 | [diff] [blame] | 511 | EOF |
| 512 | ---- |
| 513 | |
David Ostrovsky | fe2934e | 2014-04-22 00:36:12 +0200 | [diff] [blame] | 514 | == Rerun unit tests |
David Ostrovsky | a4ea92e7 | 2014-03-25 06:42:33 -0700 | [diff] [blame] | 515 | |
David Pursehouse | 56f60a4 | 2014-07-10 11:20:33 +0900 | [diff] [blame^] | 516 | Test execution results are cached by Buck. If a test that was already run |
| 517 | needs to be repeated, the unit test cache for that test must be removed first: |
David Ostrovsky | a4ea92e7 | 2014-03-25 06:42:33 -0700 | [diff] [blame] | 518 | |
| 519 | ---- |
| 520 | $ rm -rf buck-out/bin/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/group/.AddRemoveGroupMembersIT/ |
| 521 | ---- |
| 522 | |
David Pursehouse | 56f60a4 | 2014-07-10 11:20:33 +0900 | [diff] [blame^] | 523 | After clearing the cache, the test can be run again: |
David Ostrovsky | a4ea92e7 | 2014-03-25 06:42:33 -0700 | [diff] [blame] | 524 | |
| 525 | ---- |
| 526 | $ buck test //gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/group:AddRemoveGroupMembersIT |
| 527 | TESTING //gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/rest/group:AddRemoveGroupMembersIT |
| 528 | PASS 14,9s 8 Passed 0 Failed com.google.gerrit.acceptance.rest.group.AddRemoveGroupMembersIT |
| 529 | TESTS PASSED |
| 530 | ---- |
| 531 | |
David Pursehouse | 56f60a4 | 2014-07-10 11:20:33 +0900 | [diff] [blame^] | 532 | An alternative approach is to use Buck's `--filters` (`-f`) option: |
David Ostrovsky | a4ea92e7 | 2014-03-25 06:42:33 -0700 | [diff] [blame] | 533 | |
| 534 | ---- |
David Pursehouse | 56f60a4 | 2014-07-10 11:20:33 +0900 | [diff] [blame^] | 535 | buck test -f 'com.google.gerrit.acceptance.rest.change.SubmitByMergeAlwaysIT' |
David Ostrovsky | a4ea92e7 | 2014-03-25 06:42:33 -0700 | [diff] [blame] | 536 | TESTING SELECTED TESTS |
| 537 | PASS 14,5s 6 Passed 0 Failed com.google.gerrit.acceptance.rest.change.SubmitByMergeAlwaysIT |
| 538 | TESTS PASSED |
| 539 | ---- |
| 540 | |
David Pursehouse | 56f60a4 | 2014-07-10 11:20:33 +0900 | [diff] [blame^] | 541 | When this option is used, the cache is disabled per design and doesn't need to |
| 542 | be explicitly deleted. |
| 543 | |
| 544 | Note that when this option is used, the whole unit test cache is dropped, so |
David Ostrovsky | 074859e | 2014-04-19 22:52:47 +0200 | [diff] [blame] | 545 | repeating the |
| 546 | |
| 547 | ---- |
David Pursehouse | 56f60a4 | 2014-07-10 11:20:33 +0900 | [diff] [blame^] | 548 | buck test |
David Ostrovsky | 074859e | 2014-04-19 22:52:47 +0200 | [diff] [blame] | 549 | ---- |
| 550 | |
David Pursehouse | 56f60a4 | 2014-07-10 11:20:33 +0900 | [diff] [blame^] | 551 | causes all tests to be executed again. |
| 552 | |
| 553 | To run tests without using cached results at all, use the `--no-results-cache` |
| 554 | option: |
| 555 | |
| 556 | ---- |
| 557 | buck test --no-results-cache |
| 558 | ---- |
David Ostrovsky | a4ea92e7 | 2014-03-25 06:42:33 -0700 | [diff] [blame] | 559 | |
David Pursehouse | d0525a7 | 2013-05-09 17:49:34 +0100 | [diff] [blame] | 560 | GERRIT |
| 561 | ------ |
| 562 | Part of link:index.html[Gerrit Code Review] |
Yuxuan 'fishy' Wang | 99cb68d | 2013-10-31 17:26:00 -0700 | [diff] [blame] | 563 | |
| 564 | SEARCHBOX |
| 565 | --------- |