Merge branch 'stable-2.14' into stable-2.15

* stable-2.14:
  Update Gerrit API to 2.14.21

Change-Id: I83d56c3bddb948239702f7647268893238e58226
diff --git a/gerrit_api.bzl b/gerrit_api.bzl
index d742842..27ca508 100644
--- a/gerrit_api.bzl
+++ b/gerrit_api.bzl
@@ -6,7 +6,7 @@
 gerrit_api is rule for fetching Gerrit plugin API using Bazel.
 """
 
-VER = "2.14.21"
+VER = "2.15.18"
 
 def gerrit_api():
     bouncycastle_repos()
@@ -15,18 +15,18 @@
     maven_jar(
         name = "gerrit_plugin_api",
         artifact = "com.google.gerrit:gerrit-plugin-api:" + VER,
-        sha1 = "c7152a923d1564e092654f992ab62553c0c9b0e0",
+        sha1 = "ea03c6d58c96b2e9d41602862ed713612e558e3e",
     )
     maven_jar(
         name = "gerrit_plugin_gwtui",
         artifact = "com.google.gerrit:gerrit-plugin-gwtui:" + VER,
-        sha1 = "ce1a05823076eb9d9eb3bc1532dfdb1e156bfe41",
+        sha1 = "4c57d4fa58b7f264b6c3fcd142021e071d08ed74",
         exclude = ["com/google/gwt/*"],
     )
     maven_jar(
         name = "gerrit_acceptance_framework",
         artifact = "com.google.gerrit:gerrit-acceptance-framework:" + VER,
-        sha1 = "2f5f419e4f4d93adaaedde181c8ac2e7540f3fce",
+        sha1 = "21cc57fb3ba9cc0235bc7bec990bf23e241ad395",
     )
     native.bind(
         name = "gerrit-plugin-api",
diff --git a/gerrit_api_maven_local.bzl b/gerrit_api_maven_local.bzl
index 5e21fb7..33d9bd8 100644
--- a/gerrit_api_maven_local.bzl
+++ b/gerrit_api_maven_local.bzl
@@ -6,7 +6,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 dd7b4a8..301c817 100644
--- a/gerrit_plugin.bzl
+++ b/gerrit_plugin.bzl
@@ -33,6 +33,7 @@
         gwt_module = [],
         resources = [],
         manifest_entries = [],
+        dir_name = None,
         target_suffix = "",
         **kwargs):
     gwt_deps = []
@@ -40,6 +41,10 @@
     if gwt_module:
         static_jars = [":%s-static" % name]
         gwt_deps = GWT_PLUGIN_DEPS_NEVERLINK
+
+    if not dir_name:
+        dir_name = name
+
     java_library(
         name = name + "__plugin",
         srcs = srcs,
@@ -88,6 +93,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(
@@ -95,12 +107,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"],
     )
diff --git a/tools/eclipse/project.py b/tools/eclipse/project.py
index 9abfbef..154ae53 100755
--- a/tools/eclipse/project.py
+++ b/tools/eclipse/project.py
@@ -146,7 +146,7 @@
     if m:
       src.add(m.group(1).lstrip('/'))
     else:
-      if p.startswith("external"):
+      if ext is not None and p.startswith("external"):
         p = os.path.join(ext, p)
         lib.add(p)