Deprecate `exports` parameter in `gerrit_plugin_tests` Recently, the `ext_deps` parameter was introduced, which essentially has the same purpose as `exports`, but provides better usability. To avoid duplication, the plugin_test_deps rule generation was adapted to support both `ext_deps` and `exports`. `exports` should be removed in the future. Change-Id: Id8d54c88df63d46095ff7d13a29139dc38cb73e1
diff --git a/gerrit_plugin.bzl b/gerrit_plugin.bzl index 8e655b3..42a4bc9 100644 --- a/gerrit_plugin.bzl +++ b/gerrit_plugin.bzl
@@ -246,6 +246,7 @@ deps: List of additional Bazel dependencies for the test target. plugin: Name of the plugin under test. Only required if `exports`, `ext_deps`, or automatic plugin target wiring is used. + Only either `ext_deps` or `exports` is allowed. ext_deps: List of Maven coordinates for external test dependencies. When set, dependency tests are generated automatically. ext_repo: Name of the external repository generated by rules_jvm_external. @@ -254,7 +255,8 @@ is added automatically if not already present. exports: List of targets to export for in-tree testing. Must be used together with `plugin` argument. Targets will also be added as dependencies to - the test target created by this rule. + the test target created by this rule. Deprecated in favor of `ext_deps`. + Only either `ext_deps` or `exports` is allowed. 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. @@ -266,6 +268,9 @@ **kwargs: Additional arguments passed to the underlying `junit_tests` rule. """ + if ext_deps and exports: + fail("Only either provide `exports` (deprecated) or `ext_deps` (recommended).") + if plugin: if name == None: name = plugin + "_tests" @@ -280,9 +285,15 @@ if plugin and plugin not in tags: tags = tags + [plugin] - if exports: + if plugin: + deps = [":%s__plugin" % plugin] + deps + + if ext_deps or exports: if not plugin: - fail("plugin argument must be set when exports are provided") + fail("gerrit_plugin_tests: `plugin` must be set when `ext_deps` or `exports` is provided") + if ext_deps: + exports = _artifacts(ext_deps, ext_repo) + java_library( name = plugin + "__plugin_test_deps", testonly = True, @@ -291,14 +302,6 @@ ) deps = deps + [":" + plugin + "__plugin_test_deps"] - if plugin: - deps = [":%s__plugin" % plugin] + deps - - if ext_deps: - if ext_repo == None: - fail("gerrit_plugin_tests: `ext_repo` must be set when `ext_deps` are provided without `plugin`") - deps = deps + _artifacts(ext_deps, ext_repo) - junit_tests( name = name, srcs = srcs,