[jvm-compile][bug] Fixes other target's class dir ending up on classpath

Review Request #4198 — Created Aug. 30, 2016 and submitted

benjyw, gmalmquist, stuhood

https://rbcommons.com/s/twitter/r/3635/ introduced a regression where classpath entries for targets other than the target being compiled could end up on the compile classpath if there are multiple targets being compiled.

An example.
You tell pants to compile targets A, B and C.
When jvm_compile creates the compile jobs, it does it in the order A, B and C.
Then, for A and B instead of having their own class directories on the classpath, they'll have C's. This is because compile_context will point at C and we were using compile_context to find the class directory.

This fixes it by replacing the usages of the closed over iteration variable with the passed ctx variable.

It also adds a regression test.

Wrote failing regression test and made it pass. CI away on the linked PR.

  1. Ship It!
  1. Ship It!
  1. Ship It!
Review request changed

Status: Closed (submitted)

Change Summary:

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