Implement Bazel build
This change adds two Bazel build modes:
1. Standalone build mode (Bazlets driven)
2. In Gerrit tree build mode
Bazlets repository is currently consumed from GH, but can be moved
later to gerrit-review.
TEST PLAN:
1. run `bazel build reviewers` in reviewers project
2. link reviewers directory to gerrit/plugins and run
`bazel build plugins/reviewers` in gerrit tree
Change-Id: Ie60e32096a039f75402a202ff14556118b18d86f
diff --git a/.gitignore b/.gitignore
index aa42023..3245346 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,8 @@
*.pyc
.buckversion
/bucklets
+/bazel-bin
+/bazel-genfiles
+/bazel-out
+/bazel-reviewers
+/bazel-testlogs
diff --git a/BUILD b/BUILD
new file mode 100644
index 0000000..6086d5c
--- /dev/null
+++ b/BUILD
@@ -0,0 +1,12 @@
+load("//tools/bzl:plugin.bzl", "gerrit_plugin")
+
+gerrit_plugin(
+ name = "reviewers",
+ srcs = glob(["src/main/java/**/*.java"]),
+ gwt_module = "com.googlesource.gerrit.plugins.reviewers.ReviewersForm",
+ manifest_entries = [
+ "Gerrit-PluginName: reviewers",
+ "Gerrit-Module: com.googlesource.gerrit.plugins.reviewers.Module",
+ ],
+ resources = glob(["src/main/**/*"]),
+)
diff --git a/WORKSPACE b/WORKSPACE
new file mode 100644
index 0000000..5716471
--- /dev/null
+++ b/WORKSPACE
@@ -0,0 +1,30 @@
+workspace(name = "reviewers")
+
+load("//:bazlets.bzl", "load_bazlets")
+
+load_bazlets(
+ commit = "3bec81727c69207e591ae1761d5a78d8ec418a0b",
+ # local_path = "/home/<user>/projects/bazlets",
+)
+
+# Release Plugin API
+#load("@com_googlesource_gerrit_bazlets//:gerrit_api.bzl",
+# "gerrit_api")
+
+# Snapshot Plugin API
+load(
+ "@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl",
+ "gerrit_api_maven_local",
+)
+load(
+ "@com_googlesource_gerrit_bazlets//:gerrit_gwt.bzl",
+ "gerrit_gwt",
+)
+
+# Load release Plugin API
+# gerrit_api()
+
+# Load snapshot Plugin API
+gerrit_api_maven_local()
+
+gerrit_gwt()
diff --git a/bazlets.bzl b/bazlets.bzl
new file mode 100644
index 0000000..e14e488
--- /dev/null
+++ b/bazlets.bzl
@@ -0,0 +1,17 @@
+NAME = "com_googlesource_gerrit_bazlets"
+
+def load_bazlets(
+ commit,
+ local_path = None
+ ):
+ if not local_path:
+ native.git_repository(
+ name = NAME,
+ remote = "https://gerrit.googlesource.com/bazlets",
+ commit = commit,
+ )
+ else:
+ native.local_repository(
+ name = NAME,
+ path = local_path,
+ )
diff --git a/tools/bazel.rc b/tools/bazel.rc
new file mode 100644
index 0000000..4ed16cf
--- /dev/null
+++ b/tools/bazel.rc
@@ -0,0 +1,2 @@
+build --workspace_status_command=./tools/workspace-status.sh
+test --build_tests_only
diff --git a/tools/bzl/BUILD b/tools/bzl/BUILD
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tools/bzl/BUILD
diff --git a/tools/bzl/plugin.bzl b/tools/bzl/plugin.bzl
new file mode 100644
index 0000000..2b1df8c
--- /dev/null
+++ b/tools/bzl/plugin.bzl
@@ -0,0 +1,4 @@
+load(
+ "@com_googlesource_gerrit_bazlets//:gerrit_plugin.bzl",
+ "gerrit_plugin",
+)
diff --git a/tools/workspace-status.sh b/tools/workspace-status.sh
new file mode 100755
index 0000000..674faeb
--- /dev/null
+++ b/tools/workspace-status.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+# This script will be run by bazel when the build process starts to
+# generate key-value information that represents the status of the
+# workspace. The output should be like
+#
+# KEY1 VALUE1
+# KEY2 VALUE2
+#
+# If the script exits with non-zero code, it's considered as a failure
+# and the output will be discarded.
+
+function rev() {
+ cd $1; git describe --always --match "v[0-9].*" --dirty
+}
+
+echo STABLE_BUILD_REVIEWERS_LABEL $(rev .)