Add support for Bazel in Gerrit tree build

Change-Id: I2bade6e442d42b70dea6b4d02830a35e469909ab
diff --git a/BUILD b/BUILD
new file mode 100644
index 0000000..19ca99d
--- /dev/null
+++ b/BUILD
@@ -0,0 +1,38 @@
+load("//tools/bzl:junit.bzl", "junit_tests")
+load(
+    "//tools/bzl:plugin.bzl",
+    "gerrit_plugin",
+    "PLUGIN_DEPS",
+    "PLUGIN_TEST_DEPS",
+)
+
+gerrit_plugin(
+    name = "its-rtc",
+    srcs = glob(["src/main/java/**/*.java"]),
+    resources = glob(["src/main/resources/**/*"]),
+    manifest_entries = [
+        "Gerrit-PluginName: its-rtc",
+        "Gerrit-Module: com.googlesource.gerrit.plugins.its.rtc.RTCModule",
+        "Gerrit-InitStep: com.googlesource.gerrit.plugins.its.rtc.InitRTC",
+        "Gerrit-ReloadMode: reload",
+        "Implementation-Title: Plugin its-rtc",
+        "Implementation-URL: http://www.gerritforge.com",
+    ],
+    deps = [
+        "//plugins/its-base",
+        "@commons_logging//jar",
+        "@commons_io//jar:neverlink",
+        "@commons_codec//jar:neverlink",
+    ],
+)
+
+junit_tests(
+    name = "its_rtc_tests",
+    srcs = glob(["src/test/java/**/*.java"]),
+    tags = ["its-rtc"],
+    deps = PLUGIN_DEPS + PLUGIN_TEST_DEPS + [
+        ":its-rtc__plugin",
+        "//plugins/its-base:its-base",
+        "@mockito//jar",
+    ],
+)
diff --git a/external_plugin_deps.bzl b/external_plugin_deps.bzl
new file mode 100644
index 0000000..df3c787
--- /dev/null
+++ b/external_plugin_deps.bzl
@@ -0,0 +1,14 @@
+load("//tools/bzl:maven_jar.bzl", "maven_jar")
+
+def external_plugin_deps():
+  maven_jar(
+    name = 'commons_logging',
+    artifact = 'commons-logging:commons-logging:1.2',
+    sha1 = '4bfc12adfe4842bf07b657f0369c4cb522955686',
+  )
+
+  maven_jar(
+    name = 'mockito',
+    artifact = 'org.mockito:mockito-all:1.9.5',
+    sha1 = '79a8984096fc6591c1e3690e07d41be506356fa5',
+  )
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md
index 6a40483..039ab8d 100644
--- a/src/main/resources/Documentation/build.md
+++ b/src/main/resources/Documentation/build.md
@@ -1,16 +1,25 @@
 Build
 =====
 
-This @PLUGIN@ plugin is built with Buck.
+This @PLUGIN@ plugin is built with Bazel.
 
 Clone (or link) both this plugin and also
 [plugins/its-base](https://gerrit-review.googlesource.com/#/admin/projects/plugins/its-base)
 to the `plugins` directory of Gerrit's source tree.
 
+Put the external dependency Bazel build file into the Gerrit /plugins directory,
+replacing the existing empty one.
+
+```
+  cd gerrit/plugins
+  rm external_plugin_deps.bzl
+  ln -s @PLUGIN@/external_plugin_deps.bzl .
+```
+
 Then issue
 
 ```
-  buck build plugins/@PLUGIN@
+  bazel build plugins/@PLUGIN@
 ```
 
 in the root of Gerrit's source tree to build
@@ -18,10 +27,12 @@
 The output is created in
 
 ```
-  buck-out/gen/plugins/@PLUGIN@/@PLUGIN@.jar
+  bazel-genfiles/plugins/@PLUGIN@/@PLUGIN@.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
@@ -30,7 +41,7 @@
 To execute the tests run:
 
 ```
-  buck test --all --include @PLUGIN@
+  bazel test plugins/@PLUGIN@:its_rtc_tests
 ```
 
 [Back to @PLUGIN@ documentation index][index]