rules_jvm_external
rules_jvm_external copied to clipboard
Support providing maven coordinates using libs.toml files
It would be great to support passing libs.toml
files containing maven coordinates into rules_jvm_external
.
Gradle already supports this format: https://docs.gradle.org/current/userguide/platforms.html#sub:conventional-dependencies-toml
I see a few benefits:
- Would help improve dependency management and let tools like
dependabot
andrenovate
help manage automatically bumping version updates. - Would reduce the need to clutter our
MODULE.bazel
with giant lists of maven dependencies.
Potential issues:
- Conveying attributes like
testonly
,neverlink
, andpackaging (aar|jar|...)
might be harder. Technically this is supported by the Toml format already but we would need to document this.
Example:
# MODULE.bazel
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
# Toml file containing all of the maven coords
toml = "//:deps.toml",
)
# deps.toml
[versions]
androix-activity-version = "1.8.0"
androidx-experiemental-version = "1.3.0"
...
[libraries]
androidx-activity-compose = { module = "androidx.activity:activity-compose", package = "aar", version.ref = "androix-activity-version" }
androidx-activity-ktx = { module = "androidx.activity:activity-ktx", package = "aar", version.ref = "androix-activity-version" }
...
Being able to pass in a file for listing dependencies is something we've discussed in order to make bzlmod
support a bit cleaner. The constraint is that we'd like that file to be parseable in Starlark only, since this will be executed in a repository_rule
, and external commands invoked in those are highly dependent on the user's configuration (rather than being part of a potentially hermetic build)
The chances are that a JSON-based syntax will be used, though I can see the attraction of being able to inject Gradle's format, particularly when migrating projects.
I'm planning the approach we could take to handling listing dependencies in an external file. Comments are welcome.