The way the module extension is implemented doesn't actually allow you to override client versions because there will then be a name collision.
To reproduce, edit internal/test/bcr/MODULE.bazel. Notice, I haven't even tried to change versions yet, just re-use the defaults.
diff --git a/internal/test/bcr/MODULE.bazel b/internal/test/bcr/MODULE.bazel
index 0e2af0b..4938d37 100644
--- a/internal/test/bcr/MODULE.bazel
+++ b/internal/test/bcr/MODULE.bazel
@@ -9,5 +9,6 @@ local_path_override(
path = "../../..",
)
openapi_gen = use_extension("@openapi_tools_generator_bazel//:extension.bzl", "openapi_gen")
+openapi_gen.client()
use_repo(openapi_gen, "openapi_tools_generator_bazel_cli")
Then, from the internal/test/bcr directory: bazel build ... yields
❯ bazel build ...
ERROR: /home/user/.cache/bazel/_bazel_user/bd3dd79c0d936347dcd08a9f7a9427e7/external/bazel_tools/tools/build_defs/repo/jvm.bzl:306:24: Traceback (most recent call last):
File "/home/user/.cache/bazel/_bazel_user/bd3dd79c0d936347dcd08a9f7a9427e7/external/openapi_tools_generator_bazel+/extension.bzl", line 7, column 38, in _openapi_generator_impl
jvm_maven_import_external(
File "/home/user/.cache/bazel/_bazel_user/bd3dd79c0d936347dcd08a9f7a9427e7/external/bazel_tools/tools/build_defs/repo/jvm.bzl", line 306, column 24, in jvm_maven_import_external
jvm_import_external(
Error in repository_rule: A repo named openapi_tools_generator_bazel_cli is already generated by this module extension at /home/user/.cache/bazel/_bazel_user/bd3dd79c0d936347dcd08a9f7a9427e7/external/bazel_tools/tools/build_defs/repo/jvm.bzl:306:24
ERROR: Analysis of target '//:pylib' failed; build aborted: error evaluating module extension @@openapi_tools_generator_bazel+//:extension.bzl%openapi_gen
INFO: Elapsed time: 0.405s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
This is because this nested for loop is adding duplicated repos with the name openapi_tools_generator_bazel_cli. I'm not 100% sure how the resolution should be done. The names of the repos can either be adjusted to include the version (which would then require users to always specify the openapi_generator_cli attribute to the openapi_generator rule), or there can be some logic to decide which version should be used (max version?).
Temporarily we are resolving it by applying a patch which modifies the default value to what we need it to be, but I'd love to have this fixed properly. I can contribute, but I don't know the best practices for bazel module extensions well enough to know what the solution should be.
The way the module extension is implemented doesn't actually allow you to override client versions because there will then be a name collision.
To reproduce, edit
internal/test/bcr/MODULE.bazel. Notice, I haven't even tried to change versions yet, just re-use the defaults.Then, from the
internal/test/bcrdirectory:bazel build ...yieldsThis is because this nested for loop is adding duplicated repos with the name
openapi_tools_generator_bazel_cli. I'm not 100% sure how the resolution should be done. The names of the repos can either be adjusted to include the version (which would then require users to always specify theopenapi_generator_cliattribute to the openapi_generator rule), or there can be some logic to decide which version should be used (max version?).Temporarily we are resolving it by applying a patch which modifies the default value to what we need it to be, but I'd love to have this fixed properly. I can contribute, but I don't know the best practices for bazel module extensions well enough to know what the solution should be.