- Notifications
You must be signed in to change notification settings - Fork4.3k
How can I dynamically share and update Maven artifact versions across multiple MODULE.bazel files using Bzlmod?#27386
-
🧩 Title:How can I dynamically share and update Maven artifact versions across multiple MODULE.bazel files using Bzlmod? 📝 Description:Hi Bazel team 👋 I’m currently working in a large Bazel monorepo where we useBzlmod and Both define Maven repositories and should stay in sync automatically. 💡 What we’ve tried so far
❓ The questionIs there an officially supported or recommended way inBzlmod to:
Essentially:
⚙️ Context
But Bazel currently doesn’t seem to allow reading a generated repo in another module file in the same evaluation phase. 💬 Expected outcomeA supported pattern (or documentation reference) forsharing dynamically generated data (like Maven versions) between multiple Would this be possible through:
🙏 Thank youAny guidance or official example on this kind of multi-MODULE shared state in Bzlmod would be greatly appreciated. —
Would you like me to make it slightly shorter and more “GitHub issue” friendly (i.e. fewer explanations, more condensed)? |
BetaWas this translation helpful?Give feedback.
All reactions
In the latestrules_jvm_external release, we added support for reading dependencies from aGradle version catalog. This can be accessed usingfrom_toml tag. That sounds like it'd be the right fit for this problem.
One property that this has is that there are many tools that understand the format of this file, and can do useful things like automatically update dependencies.
Replies: 3 comments 3 replies
-
Given that .MODULE.bazel no longer supports load(), what is the recommended pattern in Bzlmod for: Specifically: How can multiple module files reference the same dynamically generated repository (e.g., @versions_repo) or shared version constants, when Bazel’s module evaluation model prevents load() and same-phase repo access? |
BetaWas this translation helpful?Give feedback.
All reactions
-
In the latest One property that this has is that there are many tools that understand the format of this file, and can do useful things like automatically update dependencies. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
Hi and thanks👋 [versions] [libraries] Then in my MODULE.bazel file, I added: But when I run REPIN=1 bazel run @maven//:pin, I don’t see any of these versions or dependencies appearing in the generated maven_install.json file. Am I missing a step — do I need to reference the maven_deps tag somehow inside maven.install() or use another attribute to make the TOML versions apply? |
BetaWas this translation helpful?Give feedback.
All reactions
-
Thanks, it’s all working for me now! 🙌 |
BetaWas this translation helpful?Give feedback.
All reactions
-
Wouldhttps://bazel.build/rules/lib/globals/module#include help with your use case? |
BetaWas this translation helpful?Give feedback.
All reactions
-
No, include is meant for importing another Bazel module file, not for this purpose. |
BetaWas this translation helpful?Give feedback.