Add support for Bazel in Gerrit tree build

Change-Id: I5a666053543f8581659449b6a57e139214285b5d
diff --git a/BUILD b/BUILD
new file mode 100644
index 0000000..ed8ba85
--- /dev/null
+++ b/BUILD
@@ -0,0 +1,20 @@
+load("//tools/bzl:plugin.bzl", "gerrit_plugin")
+
+gerrit_plugin(
+    name = "rabbitmq",
+    srcs = glob(["src/main/java/**/*.java"]),
+    resources = glob(["src/main/resources/**/*"]),
+    manifest_entries = [
+        "Gerrit-PluginName: rabbitmq",
+        "Gerrit-Module: com.googlesource.gerrit.plugins.rabbitmq.Module",
+        "Implementation-Title: Gerrit rabbitmq plugin",
+        "Implementation-URL: https://github.com/rinrinne/gerrit-rabbitmq-plugin",
+    ],
+    deps = [
+        "@amqp_client//jar",
+        "@commons_codec//jar:neverlink",
+        "@commons_io//jar:neverlink",
+        "@commons_lang//jar:neverlink",
+        "@gson//jar:neverlink",
+    ],
+)
diff --git a/external_plugin_deps.bzl b/external_plugin_deps.bzl
new file mode 100644
index 0000000..d778d28
--- /dev/null
+++ b/external_plugin_deps.bzl
@@ -0,0 +1,8 @@
+load("//tools/bzl:maven_jar.bzl", "maven_jar")
+
+def external_plugin_deps():
+  maven_jar(
+    name = 'amqp_client',
+    artifact = 'com.rabbitmq:amqp-client:3.5.2',
+    sha1 = '8d10edd29e08f78349bd1da9d18f81c9f8b90567',
+  )
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md
index 38c3bb5..f6656f0 100644
--- a/src/main/resources/Documentation/build.md
+++ b/src/main/resources/Documentation/build.md
@@ -1,73 +1,37 @@
 Build
 =====
 
-This plugin is built with Buck.
+This @PLUGIN@ plugin is built with Bazel.
 
-Two build modes are supported: Standalone and in Gerrit tree. Standalone
-build mode is recommended, as this mode doesn't require local Gerrit
-tree to exist.
+Clone (or link) this plugin to the `plugins` directory of Gerrit's source tree.
 
-Build standalone
-----------------
-
-Clone bucklets library:
+Put the external dependency Bazel build file into the Gerrit /plugins directory,
+replacing the existing empty one.
 
 ```
-  git clone https://gerrit.googlesource.com/bucklets
-
-```
-and link it to rabbitmq directory:
-
-```
-  cd rabbitmq && ln -s ../bucklets .
+  cd gerrit/plugins
+  rm external_plugin_deps.bzl
+  ln -s @PLUGIN@/external_plugin_deps.bzl .
 ```
 
-Add link to the .buckversion file:
+Then issue
 
 ```
-  cd rabbitmq && ln -s bucklets/buckversion .buckversion
+  bazel build plugins/@PLUGIN@
 ```
 
-Add link to the .watchmanconfig file:
-
-```
-  cd rabbitmq && ln -s bucklets/watchmanconfig .watchmanconfig
-```
-
-To build the plugin, issue the following command:
-
-
-```
-  buck build plugin
-```
+in the root of Gerrit's source tree to build
 
 The output is created in
 
 ```
-  buck-out/gen/rabbitmq.jar
+  bazel-genfiles/plugins/@PLUGIN@/@PLUGIN@.jar
 ```
 
-Build in Gerrit tree
---------------------
-
-Clone or link this plugin to the plugins directory of Gerrit's source
-tree, and issue the command:
-
-```
-  buck build plugins/rabbitmq
-```
-
-The output is created in
-
-```
-  buck-out/gen/plugins/rabbitmq/rabbitmq.jar
-```
-
-This project can be imported into the Eclipse IDE:
+This project can be imported into the Eclipse IDE.
+Add the plugin name to the `CUSTOM_PLUGINS` set in
+Gerrit core in `tools/bzl/plugins.bzl`, and execute:
 
 ```
   ./tools/eclipse/project.py
 ```
-
-How to build the Gerrit Plugin API is described in the [Gerrit
-documentation](../../../Documentation/dev-buck.html#_extension_and_plugin_api_jar_files).