Move generation of dependency tests to gerrit_plugin

The dependency tests were generated when external test deps existed.
This was wrong, since these tests care about external dependencies that
are built into the plugin jar file and not just used during tests.

Thus, create those tests during plugin build rule generation, if
the plugin uses external dependencies during build and runtime.

Change-Id: I623fd86567bb69429b2b7804158f2e3f4c55294a
diff --git a/gerrit_plugin.bzl b/gerrit_plugin.bzl
index 0859c91..5bef560 100644
--- a/gerrit_plugin.bzl
+++ b/gerrit_plugin.bzl
@@ -113,6 +113,9 @@
         license = None,
         target_suffix = "",
         deploy_env = [],
+        dependency_test_name = None,
+        dependency_test_allowlist = None,
+        dependency_test_overlap_against = None,
         **kwargs):
     """Builds a Gerrit plugin.
 
@@ -134,6 +137,12 @@
       deploy_env: List of java_binary targets representing the runtime/deployment
         environment that will load this plugin. Dependencies shared with these
         targets are excluded from this binary's runtime classpath and deploy jar.
+      dependency_test_name: Name of the generated dependency test suite.
+        Defaults to `<plugin>_dependency_tests`.
+      dependency_test_allowlist: Optional allowlist passed to
+        `gerrit_plugin_dependency_tests()`.
+      dependency_test_overlap_against: Optional overlap manifest passed to
+        `gerrit_plugin_dependency_tests()`.
       **kwargs: Additional arguments passed to the underlying `java_library` and `java_binary` rules.
 
     This rule creates a deployable .jar file for a Gerrit plugin."""
@@ -229,6 +238,16 @@
         visibility = ["//visibility:public"],
     )
 
+    if ext_deps and plugin:
+        if dependency_test_name == None:
+            dependency_test_name = plugin + "_dependency_tests"
+        gerrit_plugin_dependency_tests(
+            plugin = plugin,
+            name = dependency_test_name,
+            allowlist = dependency_test_allowlist,
+            overlap_against = dependency_test_overlap_against,
+        )
+
 def gerrit_plugin_ext_test_deps(
         plugin,
         ext_deps,
@@ -280,10 +299,6 @@
         ext_deps_label = None,
         ext_repo = None,
         tags = None,
-        skip_dependency_tests = False,
-        dependency_test_name = None,
-        dependency_test_allowlist = None,
-        dependency_test_overlap_against = None,
         **kwargs):
     """Runs junit tests for a Gerrit plugin.
 
@@ -306,14 +321,6 @@
         Defaults to `<plugin>_plugin_deps`.
       tags: Optional list of tags for the test target. If `plugin` is set, it
         is added automatically if not already present.
-      skip_dependency_tests: Whether to skip generating dependency tests when
-        `ext_deps` and `plugin` are set. Defaults to `False`.
-      dependency_test_name: Name of the generated dependency test suite.
-        Defaults to `<plugin>_dependency_tests`.
-      dependency_test_allowlist: Optional allowlist passed to
-        `gerrit_plugin_dependency_tests()`.
-      dependency_test_overlap_against: Optional overlap manifest passed to
-        `gerrit_plugin_dependency_tests()`.
       **kwargs: Additional arguments passed to the underlying `junit_tests` rule.
     """
 
@@ -355,16 +362,6 @@
         **kwargs
     )
 
-    if not skip_dependency_tests and (ext_deps or ext_deps_label) and plugin:
-        if dependency_test_name == None:
-            dependency_test_name = plugin + "_dependency_tests"
-        gerrit_plugin_dependency_tests(
-            plugin = plugin,
-            name = dependency_test_name,
-            allowlist = dependency_test_allowlist,
-            overlap_against = dependency_test_overlap_against,
-        )
-
 def gerrit_plugin_test_util(
         name,
         srcs = [],