Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

maven_jars generates duplicate build targets for dependencies #26

Open
cdfa opened this issue Jun 11, 2019 · 2 comments
Open

maven_jars generates duplicate build targets for dependencies #26

cdfa opened this issue Jun 11, 2019 · 2 comments

Comments

@cdfa
Copy link

cdfa commented Jun 11, 2019

It seems maven_jars can't deal with packages occurring multiple times in the dependency tree.

Steps to reproduce

  1. Create a BUILD file with:
maven_jars(
    name = "owl-api",
    id = "net.sourceforge.owlapi:owlapi-distribution:5.1.0",
)
  1. plz build :owl-api

Expected results

Build succeeds without a problem

Actual results

Build stopped after 23.79s. 1 target failed:
//third_party/java:_owl-api#deps
src/parse/rules/misc_rules.build_defs:373:12: error: Duplicate build target in third_party/java: _guava#bin
url = urls[0]
return build_rule(
^
name = name,
Traceback:
src/parse/rules/misc_rules.build_defs:373:12:       return build_rule(
src/parse/rules/java_rules.build_defs:512:18:       bin_rule  =  remote_file(
plz-out/gen/pleasings/java/maven_jars.build_defs: 54:13:               maven_jar(
plz-out/gen/pleasings/java/maven_jars.build_defs: 48: 9:           for line in output:
@peterebden
Copy link
Contributor

I don't think this is quite the issue - it should indeed issue each dependency once. The above example works if I create a BUILD file with just that in it.

I think what might be happening is you have something else in the BUILD file called guava, either explicitly or as output by another maven_jars rule. If the latter you are probably best to combine them ala

maven_jars(
    name = "owl-api",
    ids = [
        "net.sourceforge.owlapi:owlapi-distribution:5.1.0",
        "io.grpc:grpc-all:1.1.2",
    ],
)

Does that help?

Alternatively we could look at using more specific package names (e.g. using a version of the complete coordinates rather than just the artifact ID) although in general that may still fail if two of them found the same version of the same package.

@cdfa
Copy link
Author

cdfa commented Jun 18, 2019

I think what might be happening is you have something else in the BUILD file called guava, either explicitly or as output by another maven_jars rule.

Ah, indeed, we also have the guava package from grpc-all. Combining them into a single maven_jars will probably work, but if I have one rule that only depends on the grpc jars and one that only depends on the owlapi jars, won't both dependants get all jars and have their resulting .jar size needlessly increased?

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

No branches or pull requests

2 participants