bazel-contrib / rules_jvm_external

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

bzlmod: when root module overrides a namespace but doesn't change artifacts, do not emit a warning #1193

Open brianantony456 opened 4 months ago

brianantony456 commented 4 months ago

Reproduced in examples bzlmod project

The documentation states that one can override the rules_jvm_external lock file with bzlmod, however we end up many warning during build.

bazel_dep(name = "rules_jvm_external", version = "6.2")

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")

# Repin everything with `REPIN=1 bazel run @maven_repo//:pin`
# Overwrite rules_jvm_external internal maven file
maven.install(
    name = "rules_jvm_external_deps",
    repositories = [
        "https://repo1.maven.org/maven2",
        "https://packages.atlassian.com/mvn/maven-atlassian-external/",
    ],
    lock_file = "//:rules_jvm_external_deps_install.json",
)

# Named as maven_repo to prevent conflict with protobuf's default "maven" repo name
maven.install(
    name = "maven_repo",
    artifacts = [
        # Obtained from: https://github.com/jflex-de/bazel_rules/blob/master/jflex/deps.bzl
        "de.jflex:jflex:jar:1.9.1",
        "com.github.vbmacher:java-cup-runtime:jar:11b-20160615-1",
    ],
    # Currently the sources are not required, enable if necessary.
    fetch_sources = False,
    # On change, comment out lock_file input, update file with: bazelisk run @maven//:pin
    lock_file = "//:maven_install.json",
    # TODO: DECIDE: Use only our internal repository which acts as a transparent proxy.
    repositories = [
        "https://repo1.maven.org/maven2",
        "https://packages.atlassian.com/mvn/maven-atlassian-external/",
    ],
)
use_repo(maven, "maven_repo")

Warnings thrown

DEBUG: /workspaces//483e35951be2410848d0b4cbe4058b2f/external/rules_jvm_external~6.2/private/extensions/maven.bzl:156:14: The maven repository 'rules_jvm_external_deps' is used in two different bazel modules, originally in 'example' and now in 'rules_jvm_external'
DEBUG: /workspaces/.bazel/483e35951be2410848d0b4cbe4058b2f/external/rules_jvm_external~6.2/private/extensions/maven.bzl:156:14: The maven repository 'rules_jvm_external_deps' is used in two different bazel modules, originally in 'example' and now in 'rules_jvm_external'
DEBUG: /workspaces//.bazel/483e35951be2410848d0b4cbe4058b2f/external/rules_jvm_external~6.2/private/extensions/maven.bzl:156:14: The maven repository 'rules_jvm_external_deps' is used in two different bazel modules, originally in 'example' and now in 'rules_jvm_external'

Bazel version

7.0.1

rules_jvm_external version

6.2

shs96c commented 4 months ago

The warning is expected. Without it, there's no way to know that other modules are contributing to a particular set of artifacts being resolved. However, in this case, where the root module isn't contributing to the set of artifacts, perhaps it would be nicer to omit the warning. I'll retitle this issue, and add the concern to the design doc for module layering.