Add support for Bazel in Gerrit tree build
Change-Id: I67a8c8b9e7e7139e54368016f49dff821708ad95
diff --git a/.buckconfig b/.buckconfig
deleted file mode 100644
index 112615b..0000000
--- a/.buckconfig
+++ /dev/null
@@ -1,10 +0,0 @@
-[alias]
- automerger = //:automerger
- plugin = //:automerger
-[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 95b0c44..0000000
--- a/BUCK
+++ /dev/null
@@ -1,58 +0,0 @@
-include_defs('//bucklets/gerrit_plugin.bucklet')
-include_defs('//bucklets/maven_jar.bucklet')
-
-gerrit_plugin(
- name = 'automerger',
- srcs = glob(['src/main/java/**/*.java']),
- resources = glob(['src/main/**/*']),
- manifest_entries = [
- 'Gerrit-PluginName: automerger',
- 'Gerrit-Module: com.googlesource.gerrit.plugins.automerger.AutomergerModule',
- 'Implementation-Title: Automerger plugin',
- 'Implementation-URL: https://gerrit-review.googlesource.com/#/admin/projects/plugins/automerger',
- ],
- deps = [
- ':re2j',
- ':yaml',
- ],
-)
-
-define_license(name = 're2j')
-
-maven_jar(
- name = 'yaml',
- id = 'org.yaml:snakeyaml:1.17',
- sha1 = '7a27ea250c5130b2922b86dea63cbb1cc10a660c',
- license = 'Apache2.0',
-)
-
-maven_jar(
- name = 'mockito',
- id = 'org.mockito:mockito-all:1.10.19',
- sha1 = '539df70269cc254a58cccc5d8e43286b4a73bf30',
- license = 'DO_NOT_DISTRIBUTE',
-)
-
-maven_jar(
- name = 're2j',
- id = 'com.google.re2j:re2j:1.0',
- sha1 = 'd24ac5f945b832d93a55343cd1645b1ba3eca7c3',
- license = 're2j',
- local_license = True,
-)
-
-java_test(
- name = 'automerger_tests',
- srcs = glob(['src/test/java/**/*.java']),
- resources = glob(['src/test/resources/**/*']),
- labels = ['automerger'],
- deps = GERRIT_PLUGIN_API + GERRIT_TESTS + [
- ':automerger__plugin',
- ':mockito',
- ],
-)
-
-java_library(
- name = 'classpath',
- deps = [':automerger__plugin'] + GERRIT_PLUGIN_API,
-)
diff --git a/BUILD b/BUILD
new file mode 100644
index 0000000..a8d88ae
--- /dev/null
+++ b/BUILD
@@ -0,0 +1,29 @@
+load("//tools/bzl:junit.bzl", "junit_tests")
+load("//tools/bzl:plugin.bzl", "gerrit_plugin", "PLUGIN_DEPS", "PLUGIN_TEST_DEPS")
+
+gerrit_plugin(
+ name = "automerger",
+ srcs = glob(["src/main/java/**/*.java"]),
+ manifest_entries = [
+ "Gerrit-PluginName: automerger",
+ "Gerrit-Module: com.googlesource.gerrit.plugins.automerger.AutomergerModule",
+ "Implementation-Title: Automerger plugin",
+ "Implementation-URL: https://gerrit-review.googlesource.com/#/admin/projects/plugins/automerger",
+ ],
+ resources = glob(["src/main/resources/**/*"]),
+ deps = [
+ "@re2j//jar",
+ "@yaml//jar",
+ ],
+)
+
+junit_tests(
+ name = "automerger_tests",
+ srcs = glob(["src/test/java/**/*.java"]),
+ resources = glob(["src/test/resources/**/*"]),
+ tags = ["automerger"],
+ deps = PLUGIN_DEPS + PLUGIN_TEST_DEPS + [
+ ":automerger__plugin",
+ "@mockito//jar",
+ ],
+)
diff --git a/external_plugin_deps.bzl b/external_plugin_deps.bzl
new file mode 100644
index 0000000..0396eea
--- /dev/null
+++ b/external_plugin_deps.bzl
@@ -0,0 +1,20 @@
+load("//tools/bzl:maven_jar.bzl", "maven_jar")
+
+def external_plugin_deps():
+ maven_jar(
+ name = 'yaml',
+ artifact = 'org.yaml:snakeyaml:1.17',
+ sha1 = '7a27ea250c5130b2922b86dea63cbb1cc10a660c',
+ )
+
+ maven_jar(
+ name = 'mockito',
+ artifact = 'org.mockito:mockito-all:1.10.19',
+ sha1 = '539df70269cc254a58cccc5d8e43286b4a73bf30',
+ )
+
+ maven_jar(
+ name = 're2j',
+ artifact = 'com.google.re2j:re2j:1.0',
+ sha1 = 'd24ac5f945b832d93a55343cd1645b1ba3eca7c3',
+ )
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md
index 24145f3..5ea4113 100644
--- a/src/main/resources/Documentation/build.md
+++ b/src/main/resources/Documentation/build.md
@@ -1,74 +1,56 @@
Build
=====
-This plugin can be built with Buck.
-
-Buck
-----
-
-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.
-
-
-### Build standalone
-
-Clone bucklets library:
-
-```
- git clone https://gerrit.googlesource.com/bucklets
-
-```
-and link it to automerger plugin directory:
-
-```
- cd automerger && ln -s ../bucklets .
-```
-
-Add link to the .buckversion file:
-
-```
- cd automerger && ln -s bucklets/buckversion .buckversion
-```
-
-Add link to the .watchmanconfig file:
-```
- cd automerger && ln -s bucklets/watchmanconfig .watchmanconfig
-```
-
-To build the plugin, issue the following command:
-
-
-```
- buck build plugin
-```
-
-The output is created in
-
-```
- buck-out/gen/automerger.jar
-```
-
-### Build in Gerrit tree
+This plugin is built using Bazel.
+Only the Gerrit in-tree build is supported.
Clone or link this plugin to the plugins directory of Gerrit's source
-tree, and issue the command:
+tree.
```
- buck build plugins/automerger
+ git clone https://gerrit.googlesource.com/gerrit
+ git clone https://gerrit.googlesource.com/plugins/automerger
+ cd gerrit/plugins
+ ln -s ../../automerger .
+```
+
+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 automerger/external_plugin_deps.bzl .
+```
+
+From Gerrit source tree issue the command:
+
+```
+ bazel build plugins/automerger
```
The output is created in
```
- buck-out/gen/plugins/automerger/automerger.jar
+ bazel-genfiles/plugins/automerger/automerger.jar
```
-This project can be imported into the Eclipse IDE:
+To execute the tests run:
+
+```
+ bazel test plugins/automerger:automerger_tests
+```
+
+or filtering using the comma separated tags:
+
+````
+ bazel test --test_tag_filters=automerger //...
+````
+
+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).