Add support for Bazel in Gerrit tree build

Change-Id: Id5078e7cf5dfa7890b7332a37bcc17685d8489d3
diff --git a/BUILD b/BUILD
new file mode 100644
index 0000000..f432553
--- /dev/null
+++ b/BUILD
@@ -0,0 +1,13 @@
+load("//tools/bzl:plugin.bzl", "gerrit_plugin")
+
+gerrit_plugin(
+    name = "metrics-reporter-elasticsearch",
+    srcs = glob(["src/main/java/**/*.java"]),
+    resources = glob(["src/main/resources/**/*"]),
+    manifest_entries = [
+        "Gerrit-PluginName: metrics-reporter-elasticsearch",
+    ],
+    deps = [
+        "@metrics_elasticsearch_reporters//jar",
+    ],
+)
diff --git a/external_plugin_deps.bzl b/external_plugin_deps.bzl
new file mode 100644
index 0000000..6c6cdd6
--- /dev/null
+++ b/external_plugin_deps.bzl
@@ -0,0 +1,34 @@
+load("//tools/bzl:maven_jar.bzl", "maven_jar")
+
+def external_plugin_deps():
+  maven_jar(
+    name = 'metrics_elasticsearch_reporters',
+    artifact = 'org.elasticsearch:metrics-elasticsearch-reporter:2.0',
+    sha1 = '399ff7b3378e94be017f475a114227acc41b7b31',
+    deps = [
+      '@jackson_databind//jar',
+      '@jackson_core//jar',
+    ],
+  )
+
+  maven_jar(
+    name = 'jackson_databind',
+    artifact = 'com.fasterxml.jackson.core:jackson-databind:2.2.3',
+    sha1 = '03ae380888029daefb91d3ecdca3a37d8cb92bc9',
+    deps = [
+      '@jackson_core//jar',
+      '@jackson_annotations//jar',
+    ],
+  )
+
+  maven_jar(
+    name = 'jackson_core',
+    artifact = 'com.fasterxml.jackson.core:jackson-core:2.2.3',
+    sha1 = '1a0113da2cab5f4c216b4e5e7c1dbfaa67087e14',
+  )
+
+  maven_jar(
+    name = 'jackson_annotations',
+    artifact = 'com.fasterxml.jackson.core:jackson-annotations:2.2.3',
+    sha1 = '0527fece4f23a457070a36c371a26d6c0208e1c3',
+  )
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md
new file mode 100644
index 0000000..ba9f1b5
--- /dev/null
+++ b/src/main/resources/Documentation/build.md
@@ -0,0 +1,41 @@
+Build
+=====
+
+This plugin is built with Bazel.
+
+Clone (or link) this plugin 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
+
+```
+  bazel build plugins/@PLUGIN@
+```
+
+in the root of Gerrit's source tree to build
+
+The output is created in
+
+```
+  bazel-genfiles/plugins/@PLUGIN@/@PLUGIN@.jar
+```
+
+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
+```
+
+[Back to @PLUGIN@ documentation index][index]
+
+[index]: index.html