thought-machine / pleasings

Addons & new build rules for Please
Apache License 2.0
98 stars 39 forks source link

maven_jars generates duplicate build targets for dependencies #26

Open cdfa opened 5 years ago

cdfa commented 5 years ago

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",
    )
  2. 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 commented 5 years ago

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 commented 5 years ago

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?