Bazel: De-duplicate plugins API in final artifact

The build implementation currently erroneously transitively depends on
the plugin API. As a consequence, the size of final artifact is 50 MB.

After fixing it, it turns out that the transitive dependency on
prolog:common rule in Gerrit core pulls in another 45 MB dependency from
Gerrit core. That is due to the fact, that prolog:common transitively
depends on gerrit-server that transitively depends on the virtually
the whole Gerrit build graph.

Fix it by exposing the missing prolog rule in the plugin API, and cut
off the prolog runtime dependency as well. Prolog runtime is already
included in the Gerrit final artifact anyway.

Change-Id: If9d249fb9bb2e67a6103159157fd7fc5d593d7cb
diff --git a/owners-common/BUILD b/owners-common/BUILD
index e44b7d7..3711359 100644
--- a/owners-common/BUILD
+++ b/owners-common/BUILD
@@ -1,3 +1,4 @@
+load("//tools/bzl:gwt.bzl", "PLUGIN_DEPS_NEVERLINK")
 load("//tools/bzl:junit.bzl", "junit_tests")
 load("//tools/bzl:plugin.bzl", "gerrit_plugin", "PLUGIN_DEPS", "PLUGIN_TEST_DEPS")
 load("//plugins/owners-common:common.bzl", "EXTERNAL_DEPS")
@@ -9,11 +10,11 @@
         "src/main/java/**/*.java",
     ]),
     visibility = ["//visibility:public"],
-    deps = PLUGIN_DEPS + EXTERNAL_DEPS,
+    deps = PLUGIN_DEPS_NEVERLINK + EXTERNAL_DEPS,
 )
 
 gerrit_plugin(
-    name = "owners_common__plugin",
+    name = "owners-common__plugin",
     srcs = glob(["src/main/java/**/*.java"]),
     resources = glob(["src/main/resources/**/*"]),
 )
diff --git a/owners/BUILD b/owners/BUILD
index ab5fc6f..f803af2 100644
--- a/owners/BUILD
+++ b/owners/BUILD
@@ -1,33 +1,31 @@
+load("//tools/bzl:gwt.bzl", "PLUGIN_DEPS_NEVERLINK")
 load("//tools/bzl:junit.bzl", "junit_tests")
 load("//tools/bzl:plugin.bzl", "gerrit_plugin", "PLUGIN_DEPS", "PLUGIN_TEST_DEPS")
 load("//lib/prolog:prolog.bzl", "prolog_cafe_library")
 load("//plugins/owners-common:common.bzl", "EXTERNAL_DEPS")
 
-COMPILE_STUB = ["src/main/java/com/vmware/gerrit/owners/CompileStub.java"]
-
 java_library(
     name = "gerrit-owners-lib",
     srcs = glob([
         "src/main/java/**/*.java",
     ]),
     deps = [
-        "@prolog_runtime//jar",
+        "@prolog_runtime//jar:neverlink",
         "//plugins/owners-common:owners-common",
-    ] + PLUGIN_DEPS + EXTERNAL_DEPS,
+    ] + PLUGIN_DEPS_NEVERLINK + EXTERNAL_DEPS,
 )
 
 prolog_cafe_library(
     name = "gerrit-owners-prolog-rules",
     srcs = glob(["src/main/prolog/*.pl"]),
-    deps = [
+    deps = PLUGIN_DEPS_NEVERLINK + [
         ":gerrit-owners-lib",
-        "//gerrit-server/src/main/prolog:common",
     ],
 )
 
 gerrit_plugin(
     name = "owners",
-    srcs = COMPILE_STUB,
+    srcs = ["src/main/java/com/vmware/gerrit/owners/CompileStub.java"],
     manifest_entries = [
         "Implementation-Title: Gerrit OWNERS plugin",
         "Implementation-URL: https://gerrit.googlesource.com/plugins/owners",