Consume events-broker from source

Also amend the build.md with the explicit mention to the events-broker
as pre-requisite for building the plugin.

Change-Id: I56648a551b8da27a7bb8fe344ce4feb4d8ec5e34
diff --git a/BUILD b/BUILD
index 9714d33..c34e07c 100644
--- a/BUILD
+++ b/BUILD
@@ -17,8 +17,8 @@
     ],
     resources = glob(["src/main/resources/**/*"]),
     deps = [
+        ":events-broker-neverlink",
         "@api-common//jar",
-        "@events-broker//jar:neverlink",
         "@gax-grpc//jar",
         "@gax//jar",
         "@google-auth-library-credentials//jar",
@@ -52,8 +52,8 @@
     deps = [
         ":events-gcloud-pubsub__plugin_test_deps",
         "//lib/testcontainers",
+        "//plugins/events-broker",
         "@api-common//jar",
-        "@events-broker//jar",
         "@gax-grpc//jar",
         "@gax//jar",
         "@google-auth-library-credentials//jar",
@@ -110,3 +110,9 @@
         "@opencensus-contrib-http-util//jar",
     ],
 )
+
+java_library(
+    name = "events-broker-neverlink",
+    neverlink = 1,
+    exports = ["//plugins/events-broker"],
+)
diff --git a/Jenkinsfile b/Jenkinsfile
index 981c2bb..04f6a4b 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,2 +1,3 @@
 pluginPipeline(formatCheckId: 'gerritforge:plugins-events-gcloud-pubsub-code-style',
-                buildCheckId: 'gerritforge:plugins-events-gcloud-pubsub-build-test')
+                buildCheckId: 'gerritforge:plugins-events-gcloud-pubsub-build-test',
+                extraModules: ['events-broker'])
diff --git a/external_plugin_deps.bzl b/external_plugin_deps.bzl
index c5b11fe..b2c0cbe 100644
--- a/external_plugin_deps.bzl
+++ b/external_plugin_deps.bzl
@@ -44,12 +44,6 @@
     )
 
     maven_jar(
-        name = "events-broker",
-        artifact = "com.gerritforge:events-broker:3.4.0.4",
-        sha1 = "8d361d863382290e33828116e65698190118d0f1",
-    )
-
-    maven_jar(
         name = "testcontainers-gcloud",
         artifact = "org.testcontainers:gcloud:1.15.2",
         sha1 = "0ad02bb83edc818469e1080995cae409f5d40694",
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md
index 73f1a9f..729cd9b 100644
--- a/src/main/resources/Documentation/build.md
+++ b/src/main/resources/Documentation/build.md
@@ -2,7 +2,8 @@
 
 The events-gcloud-pubsub plugin can be built as a regular 'in-tree' plugin. That means
 that is required to clone a Gerrit source tree first and then to have the plugin
-source directory into the `/plugins` path.
+source directory into the `/plugins` path. The plugin depends on [events-broker](https://gerrit.googlesource.com/modules/events-broker)
+which is linked directly from source with the same 'in-tree' plugin structure.
 
 Additionally, the `plugins/external_plugin_deps.bzl` file needs to be updated to
 match the events-gcloud-pubsub plugin one.
@@ -11,6 +12,7 @@
 git clone --recursive https://gerrit.googlesource.com/gerrit
 cd gerrit
 git clone "https://gerrit.googlesource.com/plugins/events-gcloud-pubsub" plugins/events-gcloud-pubsub
+git clone "https://gerrit.googlesource.com/modules/events-broker" plugins/events-broker
 ln -sf ../plugins/events-gcloud-pubsub/external_plugin_deps.bzl plugins/.
 bazelisk build plugins/events-gcloud-pubsub
 ```