Merge branch 'stable-2.14' into stable-2.15

* stable-2.14:
  Update Gerrit API to 2.14.12

Change-Id: I694807c3fe45f403767d62609047d1dab79c79e0
diff --git a/gerrit_api.bzl b/gerrit_api.bzl
index fd88c85..98be00b 100644
--- a/gerrit_api.bzl
+++ b/gerrit_api.bzl
@@ -5,7 +5,7 @@
 gerrit_api is rule for fetching Gerrit plugin API using Bazel.
 """
 
-VER = "2.14.12"
+VER = "2.15.3"
 
 def gerrit_api():
     bouncycastle_repos()
@@ -13,18 +13,30 @@
     maven_jar(
         name = "gerrit_plugin_api",
         artifact = "com.google.gerrit:gerrit-plugin-api:" + VER,
+<<<<<<< HEAD
+        sha1 = "ff44f3b4faa9d7b8845f68e3340b72d800958e7e",
+=======
         sha1 = "2056c3cd210bc500940fa2629191c90b470ea0d1",
+>>>>>>> stable-2.14
     )
     maven_jar(
         name = "gerrit_plugin_gwtui",
         artifact = "com.google.gerrit:gerrit-plugin-gwtui:" + VER,
+<<<<<<< HEAD
+        sha1 = "795c35ad561f4e78d5ac582e7d7d23bdc5363052",
+=======
         sha1 = "dd3d650ddbeb9aba32781bc6124dbe9bc5b275c9",
+>>>>>>> stable-2.14
         exclude = ["com/google/gwt/*"],
     )
     maven_jar(
         name = "gerrit_acceptance_framework",
         artifact = "com.google.gerrit:gerrit-acceptance-framework:" + VER,
+<<<<<<< HEAD
+        sha1 = "9b55aa8a1184ed9ffe4ac982e1ceb069249783f7",
+=======
         sha1 = "790327f96485afabfa158a88aac7a59fde1591e8",
+>>>>>>> stable-2.14
     )
     native.bind(
         name = "gerrit-plugin-api",
diff --git a/gerrit_api_maven_local.bzl b/gerrit_api_maven_local.bzl
index 1bb532f..e95d7d0 100644
--- a/gerrit_api_maven_local.bzl
+++ b/gerrit_api_maven_local.bzl
@@ -5,7 +5,7 @@
 gerrit_api is rule for fetching Gerrit plugin API using Bazel.
 """
 
-VER = "2.14.11-SNAPSHOT"
+VER = "2.15.2-SNAPSHOT"
 
 def gerrit_api_maven_local():
     bouncycastle_repos()
diff --git a/gerrit_plugin.bzl b/gerrit_plugin.bzl
index ce9a82f..9d8ae27 100644
--- a/gerrit_plugin.bzl
+++ b/gerrit_plugin.bzl
@@ -27,6 +27,7 @@
         gwt_module = [],
         resources = [],
         manifest_entries = [],
+        dir_name = None,
         target_suffix = "",
         **kwargs):
     gwt_deps = []
@@ -35,6 +36,9 @@
         static_jars = [":%s-static" % name]
         gwt_deps = GWT_PLUGIN_DEPS_NEVERLINK
 
+    if not dir_name:
+        dir_name = name
+
     native.java_library(
         name = name + "__plugin",
         srcs = srcs,
@@ -84,6 +88,13 @@
             jvm_args = GWT_JVM_ARGS,
         )
 
+    native.genrule(
+        name = name + "__gen_stamp_info",
+        stamp = 1,
+        cmd = "cat bazel-out/stable-status.txt | grep \"^STABLE_BUILD_%s_LABEL\" | awk '{print $$NF}' > $@" % dir_name.upper(),
+        outs = ["%s__gen_stamp_info.txt" % name],
+    )
+
     # TODO(davido): Remove manual merge of manifest file when this feature
     # request is implemented: https://github.com/bazelbuild/bazel/issues/2009
     genrule2(
@@ -91,12 +102,13 @@
         stamp = 1,
         srcs = ["%s__non_stamped_deploy.jar" % name],
         cmd = " && ".join([
-            "GEN_VERSION=$$(cat bazel-out/stable-status.txt | grep %s | cut -d ' ' -f 2)" % name.upper(),
+            "GEN_VERSION=$$(cat $(location :%s__gen_stamp_info))" % name,
             "cd $$TMP",
             "unzip -q $$ROOT/$<",
             "echo \"Implementation-Version: $$GEN_VERSION\n$$(cat META-INF/MANIFEST.MF)\" > META-INF/MANIFEST.MF",
             "zip -qr $$ROOT/$@ .",
         ]),
+        tools = [":%s__gen_stamp_info" % name],
         outs = ["%s%s.jar" % (name, target_suffix)],
         visibility = ["//visibility:public"],
     )