Implement Bazel build
Due to acceptance-framework limitation, plugin daemon tests do not
working in standalone mode. This will be fixed in follow up change.
Change-Id: Ide94e6e84d9caf7280108ab0e097915ed8f0eadd
diff --git a/.gitignore b/.gitignore
index 5e2d355..737b856 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,8 @@
.buckversion
.watchmanconfig
/bucklets
+bazel-bin
+bazel-genfiles
+bazel-out
+bazel-testlogs
+bazel-verify-status
diff --git a/BUILD b/BUILD
new file mode 100644
index 0000000..da4f636
--- /dev/null
+++ b/BUILD
@@ -0,0 +1,35 @@
+load("//tools/bzl:junit.bzl", "junit_tests")
+load(
+ "//tools/bzl:plugin.bzl",
+ "gerrit_plugin",
+ "PLUGIN_DEPS",
+ "PLUGIN_TEST_DEPS",
+)
+
+gerrit_plugin(
+ name = "verify-status",
+ srcs = glob(["src/main/java/**/*.java"]),
+ gwt_module = "com.googlesource.gerrit.plugins.verifystatus.VerifyStatusForm",
+ manifest_entries = [
+ "Gerrit-PluginName: verify-status",
+ "Gerrit-Module: com.googlesource.gerrit.plugins.verifystatus.GlobalModule",
+ "Gerrit-HttpModule: com.googlesource.gerrit.plugins.verifystatus.HttpModule",
+ "Gerrit-SshModule: com.googlesource.gerrit.plugins.verifystatus.SshModule",
+ "Gerrit-InitStep: com.googlesource.gerrit.plugins.verifystatus.init.InitPlugin",
+ "Implementation-Title: Verify Status Plugin",
+ "Implementation-URL: https://gerrit-review.googlesource.com/#/admin/projects/plugins/verify-status",
+ ],
+ provided_deps = [
+ "@commons_dbcp//jar:neverlink",
+ ],
+ resources = glob(["src/main/**/*"]),
+)
+
+junit_tests(
+ name = "verify_status_tests",
+ srcs = glob(["src/test/java/**/*IT.java"]),
+ tags = ["verify-status", "local"],
+ deps = PLUGIN_DEPS + PLUGIN_TEST_DEPS + [
+ ":verify-status__plugin",
+ ],
+)
diff --git a/WORKSPACE b/WORKSPACE
new file mode 100644
index 0000000..32846e8
--- /dev/null
+++ b/WORKSPACE
@@ -0,0 +1,40 @@
+workspace(name = "verify_status")
+
+load("//:bazlets.bzl", "load_bazlets")
+
+load_bazlets(
+ commit = "8a4cbdc993f41fcfe7290e7d1007cfedf8d87c18",
+# local_path = "/home/davido/projects/bazlets",
+)
+
+# Snapshot Plugin API
+load(
+ "@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl",
+ "gerrit_api_maven_local",
+)
+
+# Release Plugin API
+#load(
+# "@com_googlesource_gerrit_bazlets//:gerrit_api.bzl",
+# "gerrit_api",
+#)
+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()
+
+load("@com_googlesource_gerrit_bazlets//tools:maven_jar.bzl", "maven_jar")
+
+maven_jar(
+ name = "commons_dbcp",
+ artifact = "commons-dbcp:commons-dbcp:1.4",
+ sha1 = "30be73c965cc990b153a100aaaaafcf239f82d39",
+)
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/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md
index b3a336a..0bde928 100644
--- a/src/main/resources/Documentation/build.md
+++ b/src/main/resources/Documentation/build.md
@@ -1,7 +1,69 @@
@PLUGIN@ Build
==============
-This plugin can be built with Buck or Maven.
+This plugin can be built with Bazel, Buck or Maven.
+
+Bazel
+----
+
+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
+
+To build the plugin, issue the following command:
+
+
+```
+ bazel build verify-status
+```
+
+The output is created in
+
+```
+ bazel-genfiles/@PLUGIN@.jar
+```
+
+Note: The tests are not working in standalone build mode due to
+gerrit-acceptance-framework limitation.
+
+### Build in Gerrit tree
+
+Clone or link this plugin to the plugins directory of Gerrit's source
+tree, and issue the command:
+
+```
+ bazel build plugins/@PLUGIN@
+```
+
+The output is created in
+
+```
+ bazel-genfiles/plugins/@PLUGIN@/@PLUGIN@.jar
+```
+
+This project can be imported into the Eclipse IDE. List the plugin in the
+custom plugin list, in `gerrit/tools/bzl/plugins.bzl`:
+
+```
+CUSTOM_PLUGINS = [
+ [...]
+ 'verify-status',
+]
+```
+
+and issue the command:
+
+```
+ ./tools/eclipse/project_bzl.py
+```
+
+To execute the tests run:
+
+```
+ bazel test plugins/verify-status:verify_status_tests
+```
Buck
----
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..8b13789
--- /dev/null
+++ b/tools/bzl/BUILD
@@ -0,0 +1 @@
+
diff --git a/tools/bzl/junit.bzl b/tools/bzl/junit.bzl
new file mode 100644
index 0000000..3af7e58
--- /dev/null
+++ b/tools/bzl/junit.bzl
@@ -0,0 +1,4 @@
+load(
+ "@com_googlesource_gerrit_bazlets//tools:junit.bzl",
+ "junit_tests",
+)
diff --git a/tools/bzl/plugin.bzl b/tools/bzl/plugin.bzl
new file mode 100644
index 0000000..a2e438f
--- /dev/null
+++ b/tools/bzl/plugin.bzl
@@ -0,0 +1,6 @@
+load(
+ "@com_googlesource_gerrit_bazlets//:gerrit_plugin.bzl",
+ "gerrit_plugin",
+ "PLUGIN_DEPS",
+ "PLUGIN_TEST_DEPS",
+)
diff --git a/tools/workspace-status.sh b/tools/workspace-status.sh
new file mode 100755
index 0000000..2e97406
--- /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_VERIFY-STATUS_LABEL" $(rev .)