Add support for Bazel in Gerrit tree build

Change-Id: I19d4a93b467c000cdfe5acfc8f816a700a967325
diff --git a/.buckconfig b/.buckconfig
deleted file mode 100644
index 08f8872..0000000
--- a/.buckconfig
+++ /dev/null
@@ -1,14 +0,0 @@
-[alias]
-  reparent = //:reparent
-  plugin = //:reparent
-
-[java]
-  src_roots = java, resources
-
-[project]
-  ignore = .git
-
-[cache]
-  mode = dir
-  dir = buck-out/cache
-
diff --git a/BUCK b/BUCK
deleted file mode 100644
index 66cefbb..0000000
--- a/BUCK
+++ /dev/null
@@ -1,21 +0,0 @@
-include_defs('//bucklets/gerrit_plugin.bucklet')
-
-gerrit_plugin(
-  name = 'reparent',
-  srcs = glob(['src/main/java/**/*.java']),
-  resources = glob(['src/main/resources/**/*']),
-  manifest_entries = [
-    'Gerrit-PluginName: reparent',
-    'Gerrit-ApiType: plugin',
-    'Gerrit-ApiVersion: 2.12-SNAPSHOT',
-    'Gerrit-Module: com.googlesource.gerrit.plugins.reparent.Module',
-    'Gerrit-HttpModule: com.googlesource.gerrit.plugins.reparent.HttpModule',
-  ],
-)
-
-# this is required for bucklets/tools/eclipse/project.py to work
-java_library(
-  name = 'classpath',
-  deps = [':reparent__plugin'],
-)
-
diff --git a/BUILD b/BUILD
new file mode 100644
index 0000000..c350d30
--- /dev/null
+++ b/BUILD
@@ -0,0 +1,12 @@
+load("//tools/bzl:plugin.bzl", "gerrit_plugin")
+
+gerrit_plugin(
+    name = "reparent",
+    srcs = glob(["src/main/java/**/*.java"]),
+    resources = glob(["src/main/resources/**/*"]),
+    manifest_entries = [
+        "Gerrit-PluginName: reparent",
+        "Gerrit-Module: com.googlesource.gerrit.plugins.reparent.Module",
+        "Gerrit-HttpModule: com.googlesource.gerrit.plugins.reparent.HttpModule",
+    ],
+)
diff --git a/VERSION b/VERSION
deleted file mode 100644
index 9df7bf7..0000000
--- a/VERSION
+++ /dev/null
@@ -1,5 +0,0 @@
-# Used by BUCK to include "Implementation-Version" in plugin Manifest.
-# If this file doesn't exist the output of 'git describe' is used
-# instead.
-PLUGIN_VERSION = '2.12-SNAPSHOT'
-
diff --git a/lib/gerrit/BUCK b/lib/gerrit/BUCK
deleted file mode 100644
index 19e67dc..0000000
--- a/lib/gerrit/BUCK
+++ /dev/null
@@ -1,12 +0,0 @@
-include_defs('//bucklets/maven_jar.bucklet')
-
-VER = '2.12-SNAPSHOT'
-REPO = MAVEN_LOCAL
-
-maven_jar(
-  name = 'plugin-api',
-  id = 'com.google.gerrit:gerrit-plugin-api:' + VER,
-  attach_source = False,
-  repository = REPO,
-  license = 'Apache2.0',
-)
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md
index c00a9d0..bcb6830 100644
--- a/src/main/resources/Documentation/build.md
+++ b/src/main/resources/Documentation/build.md
@@ -1,68 +1,27 @@
 Build
 =====
 
-This plugin can be built with Buck or Maven.
+This @PLUGIN@ plugin is built with Bazel.
 
-Buck
-----
+Clone (or link) this plugin to the `plugins` directory of Gerrit's source tree.
 
-Two build modes are supported: Standalone and in Gerrit tree.
-The standalone build mode is recommended, as this mode doesn't require
-the Gerrit tree to exist locally.
-
-
-
-Clone bucklets library:
+Then issue
 
 ```
-  git clone https://gerrit.googlesource.com/bucklets
-
-```
-and link it to @PLUGIN@ plugin directory:
-
-```
-  cd @PLUGIN@ && ln -s ../bucklets .
+  bazel build plugins/@PLUGIN@
 ```
 
-Add link to the .buckversion file:
-
-```
-  cd @PLUGIN@ && ln -s bucklets/buckversion .buckversion
-```
-
-Add link to the .watchmanconfig file:
-```
-  cd @PLUGIN@ && 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/@PLUGIN@.jar
+  bazel-genfiles/plugins/@PLUGIN@/@PLUGIN@.jar
 ```
 
-
-Clone or link this plugin to the plugins directory of Gerrit's source
-tree, and issue the command:
-
-```
-  buck build plugins/@PLUGIN@
-```
-
-The output is created in
-
-```
-  buck-out/gen/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