Sync of https://github.com/pantsbuild/pants/commit/463038a7312ae1f1b9cfa861daba70f6b2142446