Add support for Bazel in Gerrit tree build

Change-Id: Id58fbaa7c9b701a7d8a2a6749943cfca57842174
diff --git a/BUILD b/BUILD
new file mode 100644
index 0000000..0acd015
--- /dev/null
+++ b/BUILD
@@ -0,0 +1,28 @@
+load("//tools/bzl:junit.bzl", "junit_tests")
+load(
+    "//tools/bzl:plugin.bzl",
+    "gerrit_plugin",
+    "PLUGIN_DEPS",
+    "PLUGIN_TEST_DEPS",
+)
+
+gerrit_plugin(
+    name = "ref-protection",
+    srcs = glob(["src/main/java/**/*.java"]),
+    resources = glob(["src/main/resources/**/*"]),
+    manifest_entries = [
+        "Implementation-Title: Ref Protection plugin",
+        "Implementation-URL: http://gerrit.googlesource.com/plugins/ref-protection",
+        "Gerrit-PluginName: ref-protection",
+        "Gerrit-Module: com.googlesource.gerrit.plugins.refprotection.RefProtectionModule",
+    ],
+)
+
+junit_tests(
+    name = "ref_protection_tests",
+    srcs = glob(["src/test/java/**/*.java"]),
+    tags = ["ref-protection"],
+    deps = PLUGIN_DEPS + PLUGIN_TEST_DEPS + [
+        ":ref-protection__plugin",
+    ],
+)
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md
index c1ea124..17d1f10 100644
--- a/src/main/resources/Documentation/build.md
+++ b/src/main/resources/Documentation/build.md
@@ -1,84 +1,37 @@
 Build
 =====
 
-This plugin is built with Buck.
+This 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:
+Then issue
 
 ```
-  git clone https://gerrit.googlesource.com/bucklets
-
-```
-and link it to ref-protection directory:
-
-```
-  cd ref-protection && ln -s ../bucklets .
+  bazel build plugins/ref-protection
 ```
 
-Add link to the .buckversion file:
-
-```
-  cd ref-protection && ln -s bucklets/buckversion .buckversion
-```
-
-Add link to the .watchmanconfig file:
-
-```
-  cd ref-protection && 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/ref-protection.jar
+  bazel-genfiles/plugins/ref-protection/ref-protection.jar
 ```
 
-To run unit tests, issue the following command:
-
-```
-  buck test
-```
-
-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/ref-protection
-```
-
-The output is created in
-
-```
-  buck-out/gen/plugins/ref-protection/ref-protection.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
 ```
 
-To run the unit tests and restrict to run only the tests from this plugin:
+To execute the tests run:
 
 ```
-  buck test --include ref-protection
+  bazel test plugins/ref-protection:ref_protection_tests
 ```
 
 How to build the Gerrit Plugin API is described in the [Gerrit
-documentation](../../../Documentation/dev-buck.html#_extension_and_plugin_api_jar_files).
+documentation](../../../Documentation/dev-bazel.html#_extension_and_plugin_api_jar_files).