Refactor duplicate dependency detection to be in the BUILD file parsing logic
Review Request #1362 — Created Nov. 19, 2014 and submitted
|ity, johanoskarsson, patricklaw, stuhood|
This is a refactoring of https://rbcommons.com/s/twitter/r/1332/. The intent of the original
change was to keep BUILD files from declaring the same target twice in a dependency attribute.
This refactor was done to avoid triggering this error due to implicit dependency injection.
For example, We don't really care if an explicit dependency is added to a BUILD file that
duplicates a dependency injected by a code generator like protobuf_gen.py.
Now the same case fails with:Exception message: Invalid target TargetAddressable(..., name=greet, **kwargs=...): dependencies must be unique. '3rdparty:guava' occurs more than once. while executing BUILD file /Users/zundel/Src/pants/examples/src/java/com/pants/examples/hello/greet/BUILD Loading addresses from 'examples/src/java/com/pants/examples/hello/greet' failed. referenced from examples/src/java/com/pants/examples/hello/main:main-bin referenced from examples/src/java/com/pants/examples/hello/main:main
CI is running.
I'm not sure if this is the right place for this. It would be much better if you were looking at Addresses, which are normalized. For example,
//the/same/folder/foo... etc could all refer to the same thing, and it would make sense to trigger this error.
And these can't be normalized here, because an
Addressableis (intentionally) not told what its address and relpath are.
Probably this belongs at the point where an Addressable becomes a Target:
Incorporated feedback from Patrick. Moved test back to test_build_graph and made the second address use an absolute spec.
Revision 2 (+17 -26)