Sync of https://github.com/pantsbuild/pants/commit/f65be3b781c9b0173a381b33183a4cd3f6c0214b