Load Gitiles web assets from source build The Gerrit plugin currently extracts static assets from the Gitiles servlet Maven artifact. Gerrit can only source-build Gitiles core from a modules/gitiles submodule if the plugin reads those assets from Gitiles' source-built webassets target instead. Switch the resource genrule to @gitiles//resources/com/google/gitiles:webassets and preserve the final com/google/gitiles/+static layout expected by the plugin. This keeps the plugin resource jar shape unchanged while removing its dependency on the servlet artifact for static files. This change only builds inside the Gerrit tree, once the companion change adds the gitiles source submodule and the @gitiles repository; depend on it so CI resolves @gitiles. Depends-On: https://gerrit-review.googlesource.com/c/gerrit/+/623641 Depends-On: https://gerrit-review.googlesource.com/c/gitiles/+/623621 Depends-On: https://gerrit-review.googlesource.com/c/gitiles/+/623622 Depends-On: https://gerrit-review.googlesource.com/c/zuul/jobs/+/623741 Change-Id: Iacac0788e334520057f8e7eaa435fcb7be9b1cd5
diff --git a/BUILD b/BUILD index dd927af..2297dbb 100644 --- a/BUILD +++ b/BUILD
@@ -1,5 +1,5 @@ -load("@com_googlesource_gerrit_bazlets//tools:genrule2.bzl", "genrule2") load("@com_googlesource_gerrit_bazlets//:gerrit_plugin.bzl", "gerrit_plugin", "gerrit_plugin_tests") +load("@com_googlesource_gerrit_bazlets//tools:genrule2.bzl", "genrule2") gerrit_plugin( name = "gitiles", @@ -21,11 +21,11 @@ genrule2( name = "gitiles-servlet-resources", - srcs = ["@external_deps//:com_google_gitiles_gitiles_servlet"], + srcs = ["@gitiles//resources/com/google/gitiles:webassets"], outs = ["gitiles-servlet-resources.jar"], cmd = " && ".join([ - "unzip -qd $$TMP $(location @external_deps//:com_google_gitiles_gitiles_servlet) \"com/google/gitiles/static/*\"", - "cd $$TMP/com/google/gitiles/static", + "unzip -qd $$TMP $(location @gitiles//resources/com/google/gitiles:webassets) \"+static/*\"", + "cd $$TMP/+static", # To avoid loading 3rd party resources, we adapt gitiles' CSS to # load fonts from Gerrit directly: # 1. Strip out Google font CSS imports to tmp file as in-place replace is OSX no-go @@ -34,15 +34,13 @@ "mv $$TMP/base.css.tmp base.css", # 2. Add Gerrit's fonts CSS "sed -e 's%^\\(.*Common styles and definitions.*\\)$$%" + - "\\1\\n\\n@import \"../../../styles/fonts.css\";%' base.css > $$TMP/base.css.tmp", + "\\1\\n\\n@import \"../../../styles/fonts.css\";%' base.css > $$TMP/base.css.tmp", "mv $$TMP/base.css.tmp base.css", # 3. Use Gerrit's Roboto Mono for Source Code Pro "sed -e 's/Source Code Pro/Roboto Mono/g' base.css > $$TMP/base.css.tmp", "mv $$TMP/base.css.tmp base.css", - # Switching from `static` to `+static` (see comment in plugin definiton) - "cd $$TMP/com/google/gitiles", - "mv static +static", - "zip -qr $$ROOT/$@ .", + "cd $$TMP", + "zip -qr $$ROOT/$@ +static", ]), )