Bazel: Update time attribute of file entries in plugin artifact

Due to this Bazel issue: [1] non .class file entries are normalized in
singlejar Bazel utility. As the consequence even JavaScript and HTML
files have the timestamp: 2010-01-01 00:00. This makes it problematic
to refresh the plugin artifacts in browser because of the cache if a
new plugin version is deployed in Gerrit server.

To rectify, touch the content of the plugin artifact in stamp action.

The 'touch' command uses the system default timezone if none is
supplied. This makes zip files dependent on the timezone of the
generating machine.

Zip by default stores extended attributes (eg. ctime, atime) on Unix
systems. These can be further sources of non-determinism, so switch it
off with --no-extra.

[1] https://github.com/bazelbuild/bazel/issues/10789

Bug: Issue 12349
Change-Id: I5b3bbba8a3df15f37ab1a21c48768697e8bd2f36
diff --git a/gerrit_plugin.bzl b/gerrit_plugin.bzl
index 301c817..b878179 100644
--- a/gerrit_plugin.bzl
+++ b/gerrit_plugin.bzl
@@ -102,16 +102,21 @@
 
     # TODO(davido): Remove manual merge of manifest file when this feature
     # request is implemented: https://github.com/bazelbuild/bazel/issues/2009
+    # TODO(davido): Remove manual touch command when this issue is resolved:
+    # https://github.com/bazelbuild/bazel/issues/10789
     genrule2(
         name = name + target_suffix,
         stamp = 1,
         srcs = ["%s__non_stamped_deploy.jar" % name],
         cmd = " && ".join([
+            "TZ=UTC",
+            "export TZ",
             "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/$@ .",
+            "find . -exec touch '{}' ';'",
+            "zip -Xqr $$ROOT/$@ .",
         ]),
         tools = [":%s__gen_stamp_info" % name],
         outs = ["%s%s.jar" % (name, target_suffix)],