Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for resolving Found duplicate artifact versions #708

Open
aryeh-looker opened this issue Jun 13, 2022 · 7 comments
Open

Documentation for resolving Found duplicate artifact versions #708

aryeh-looker opened this issue Jun 13, 2022 · 7 comments

Comments

@aryeh-looker
Copy link

Would be great to document best-practices for resolving duplicate artifact versions

https://github.com/bazelbuild/rules_jvm_external/blob/master/coursier.bzl#L649

@desh-woes
Copy link

+1 I am currently not sure how to go about resolving duplicate artifacts.

@shs96c
Copy link
Collaborator

shs96c commented Jan 10, 2023

Duplicate artefacts are listed when the same artefact is in the list given to maven_install. Quite often, this is because you're pulling in a constant defined in another repo and including that in your maven_install's artifacts parameter.

@AAverin
Copy link

AAverin commented Apr 28, 2023

Does it work with having multiple android version installed? How can I resolve it?

rules_jvm_external/coursier.bzl:646:18: Found duplicate artifact versions
    com.google.guava:guava has multiple versions 31.1-jre, 29.0-android, 31.0.1-android

@vorburger
Copy link
Contributor

Quite often, this is because you're pulling in a constant defined in another repo and including that in your maven_install's artifacts parameter.

A typical case of this is:

com.google.guava:guava has multiple versions 32.1.3-android, 33.0.0-jre

if you have (something) like:

maven_install(
    artifacts = IO_GRPC_GRPC_JAVA_ARTIFACTS + [
        "junit:junit:4.13.2",
        "com.google.guava:guava:33.0.0-jre",

Because IO_GRPC_GRPC_JAVA_ARTIFACTS has com.google.guava:guava:32.1.3-android.

Here is one way to fix this, as I have done here:

# This is required so that we can use duplicate_version_warning (below) and fixes
# the "com.google.guava:guava has multiple versions 32.1.3-android, 33.0.0-jre" problem.
IO_GRPC_GRPC_JAVA_ARTIFACTS_WITHOUT_GUAVA = [item for item in IO_GRPC_GRPC_JAVA_ARTIFACTS if item != "com.google.guava:guava:32.1.3-android"]

maven_install(
    artifacts = IO_GRPC_GRPC_JAVA_ARTIFACTS_WITHOUT_GUAVA + [
        "junit:junit:4.13.2",
        "com.google.guava:guava:33.0.0-jre",
    ],
    duplicate_version_warning = "error",
)

@jschaf
Copy link

jschaf commented May 13, 2024

The duplicate warning occurs when using bzlmod on an empty maven list. The trick is to add an explicit maven.artificact for guava.

bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")
bazel_dep(name = "rules_java", version = "7.5.0")
bazel_dep(name = "rules_jvm_external", version = "6.1")

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.artifact(
    artifact = "guava",
    exclusions = ["com.google.code.findbugs:jsr305"],
    group = "com.google.guava",
    version = "31.1-jre",
)
maven.install(
    name = "maven",
    lock_file = "//:maven_install.json",
    artifacts = [],
)

@ratnikov
Copy link

ratnikov commented Jun 8, 2024

Hey folks, I'm also getting these and I'd like to clean them up... However, from what I can tell my dependencies are transitive (I depend on grpc-kotlin and that depends on grpc-java). Any ideas on how I can tell it which version to use?

@vorburger
Copy link
Contributor

I've proposed a docs update in #1303 to at least make this a bit clearer and avoid some future confusion for others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants