Merge branch 'stable-2.14' into stable-2.15

* stable-2.14:
  Fix undefined variable in pkg_war.bzl

Change-Id: I75cc4127a8993d867ccd498a555a25a17591daf7
diff --git a/gerrit_api.bzl b/gerrit_api.bzl
index 3f52ee8..f1f6f87 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.19"
+VER = "2.15.12"
 
 def gerrit_api():
     bouncycastle_repos()
@@ -13,18 +13,18 @@
     maven_jar(
         name = "gerrit_plugin_api",
         artifact = "com.google.gerrit:gerrit-plugin-api:" + VER,
-        sha1 = "5bdbdc03c8905a59f736cda11923151298413693",
+        sha1 = "8e7303200a8b941139008568c2321fe89853f6e0",
     )
     maven_jar(
         name = "gerrit_plugin_gwtui",
         artifact = "com.google.gerrit:gerrit-plugin-gwtui:" + VER,
-        sha1 = "adb36af1d58a0a2a03d50f71005e52cb3409cb0d",
+        sha1 = "7fe9f36a97b4e1a3a9ca77f12225f36c1f96f746",
         exclude = ["com/google/gwt/*"],
     )
     maven_jar(
         name = "gerrit_acceptance_framework",
         artifact = "com.google.gerrit:gerrit-acceptance-framework:" + VER,
-        sha1 = "912f7161d064efe4104bf52413323a8aa69f6d0c",
+        sha1 = "b921f56bbf01cc688bb65997898a6daad5613115",
     )
     native.bind(
         name = "gerrit-plugin-api",
diff --git a/gerrit_api_maven_local.bzl b/gerrit_api_maven_local.bzl
index 8f6a8a2..3769cbb 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 4062f18..0f340bb 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"],
     )
diff --git a/tools/eclipse/project.py b/tools/eclipse/project.py
index 2271f8d..d4a978c 100755
--- a/tools/eclipse/project.py
+++ b/tools/eclipse/project.py
@@ -122,7 +122,7 @@
     if m:
       src.add(m.group(1).lstrip('/'))
     else:
-      if p.startswith("external"):
+      if ext is not None and p.startswith("external"):
         p = path.join(ext, p)
         lib.add(p)