Bazel: Implement GWT UI build for the plugins

TEST PLAN:

  $ bazel build plugins/cookbook-plugin

Deploy to the server site and verify that it works.

Change-Id: I98af807f9c92ba4ed7efad332d8fdee407bb8ce6
diff --git a/tools/bzl/gwt.bzl b/tools/bzl/gwt.bzl
index ec00613..d14e96a 100644
--- a/tools/bzl/gwt.bzl
+++ b/tools/bzl/gwt.bzl
@@ -48,6 +48,19 @@
   '-XdisableCastChecking',
 ]
 
+PLUGIN_DEPS_NEVERLINK = [
+  '//gerrit-plugin-api:lib-neverlink',
+]
+
+GWT_PLUGIN_DEPS_NEVERLINK = [
+  '//gerrit-plugin-gwtui:gwtui-api-lib-neverlink',
+  '//lib/gwt:user-neverlink',
+]
+
+GWT_PLUGIN_DEPS = [
+  '//gerrit-plugin-gwtui:gwtui-api-lib',
+]
+
 GWT_TRANSITIVE_DEPS = [
   '//lib/gwt:ant',
   '//lib/gwt:colt',
@@ -126,7 +139,7 @@
   )
 
 def _gwt_binary_impl(ctx):
-  module = MODULE
+  module = ctx.attr.module[0]
   output_zip = ctx.outputs.output
   output_dir = output_zip.path + '.gwt_output'
   deploy_dir = output_zip.path + '.gwt_deploy'
@@ -195,6 +208,7 @@
     "style": attr.string(default = "OBF"),
     "optimize": attr.string(default = "9"),
     "deps": attr.label_list(allow_files=jar_filetype),
+    "module": attr.string_list(default = [MODULE]),
     "module_deps": attr.label_list(allow_files=jar_filetype),
     "compiler_args": attr.string_list(),
     "jvm_args": attr.string_list(),
@@ -237,6 +251,7 @@
 
   gwt_binary(
     name = opt,
+    module = [MODULE],
     module_deps = [module_dep],
     deps = DEPS,
     compiler_args = args,
@@ -279,6 +294,7 @@
       user_agent = ua,
       style = 'PRETTY',
       optimize = "0",
+      module = [MODULE],
       module_deps = [':ui_module'],
       deps = DEPS,
       compiler_args = GWT_COMPILER_ARGS,