bazel-contrib / rules_jvm_external

Bazel rules to resolve, fetch and export Maven artifacts
Apache License 2.0
336 stars 256 forks source link

Support providing maven coordinates using libs.toml files #976

Open Bencodes opened 1 year ago

Bencodes commented 1 year ago

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:

Potential issues:

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" }
...
shs96c commented 1 year ago

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)

shs96c commented 1 year ago

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.

shs96c commented 1 year ago

I'm planning the approach we could take to handling listing dependencies in an external file. Comments are welcome.