[jvm-compile] Ensure all invalid dependencies of targets are correctly represented in compile graph

Review Request #4343 - Created Nov. 1, 2016 and submitted

Nick Howard (Twitter)
benjyw, jsirois, stuhood
With https://rbcommons.com/s/twitter/r/4136, I reduced the size of the dependency list for compiling each target to the direct invalid dependencies. The problem with that was that sometimes if a build cache lookup fails, there may be a valid dependency between a required dependency and the current target. If strict deps is on, this isn't an issue. But if it isn't, it can cause problems because the transitive invalid dep won't be added to the deps for the current target.

This patch adds a regression test and changes dependency gathering so that it collects the first invalid dep for every path from the current target.

Wrote a failing regression test. CI passed at https://travis-ci.org/pantsbuild/pants/builds/172133875

Nick Howard (Twitter)
Benjy Weinberger
Stu Hood
Nick Howard (Twitter)
Review request changed

Status: Closed (submitted)

Change Summary:

Submitted as https://github.com/pantsbuild/pants/commit/ffc090795bcd026db84a97a02ff15a0ccc2c7900