Repository: pantsbuild/pants

Issue:
Path hardcoding prevents analysis extraction with rsc
The `rsc` task uses different paths in `.pants.d`, but unfortunately, some amount of path depth had been assumed in the zinc analysis extraction task:
https://github.com/pantsbuild/pants/blob/37aa646cdcd0b9299b32c3ee04172c9dbb298a61/src/scala/org/pantsbuild/zinc/analysis/AnalysisMap.scala#L84-L89

This causes analysis extraction to fail under rsc with:
```
java.lang.ArrayIndexOutOfBoundsException: 1
at org.pantsbuild.zinc.analysis.AnalysisMap$$anon$1.org$pantsbuild$zinc$analysis$AnalysisMap$$anon$$filePathToClassName(AnalysisMap.scala:88)
at org.pantsbuild.zinc.analysis.AnalysisMap$$anon$1$$anonfun$definesClass$1$$anonfun$1.apply(AnalysisMap.scala:72)
at org.pantsbuild.zinc.analysis.AnalysisMap$$anon$1$$anonfun$definesClass$1$$anonfun$1.apply(AnalysisMap.scala:72)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
at scala.collection.immutable.HashSet$HashSet1.foreach(HashSet.scala:316)
at scala.collection.immutable.HashSet$HashTrieSet.foreach(HashSet.scala:972)
at scala.collection.immutable.HashSet$HashTrieSet.foreach(HashSet.scala:972)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
at scala.collection.AbstractSet.scala$collection$SetLike$$super$map(Set.scala:47)
...
```

We should probably either explicitly pass in a base to use (per target), or change the rsc path layout to allow that pattern to continue to match.


Discussion:
Relates to #7824. If we can deprecate `zinc-only` and retarget those tests to rsc, we'll get a bunch more test coverage.

Resolving patch:
diff --git a/src/python/pants/backend/jvm/subsystems/zinc.py b/src/python/pants/backend/jvm/subsystems/zinc.py
--- a/src/python/pants/backend/jvm/subsystems/zinc.py
+++ b/src/python/pants/backend/jvm/subsystems/zinc.py
@@ -32,9 +32,7 @@
 from pants.util.memo import memoized_method, memoized_property
 
 
-# TODO: To use this with the nailgun strategy, will need a publish of `rsc_2.12`: this will
-# block landing this.
-_ZINC_COMPILER_VERSION = '0.0.11'
+_ZINC_COMPILER_VERSION = '0.0.12'
 
 
 class Zinc(object):
@@ -129,7 +127,7 @@ def register_options(cls, register):
       cls.register_jvm_tool(register,
                             Zinc.ZINC_EXTRACTOR_TOOL_NAME,
                             classpath=[
-                              JarDependency('org.pantsbuild', 'zinc-extractor_2.12', '0.0.11')
+                              JarDependency('org.pantsbuild', 'zinc-extractor_2.12', '0.0.12')
                             ])
 
       # Register scalac for fixed versions of Scala, 2.10, 2.11 and 2.12.


Test patch:
diff --git a/tests/python/pants_test/backend/jvm/tasks/test_jvm_dependency_usage_integration.py b/tests/python/pants_test/backend/jvm/tasks/test_jvm_dependency_usage_integration.py
--- a/tests/python/pants_test/backend/jvm/tasks/test_jvm_dependency_usage_integration.py
+++ b/tests/python/pants_test/backend/jvm/tasks/test_jvm_dependency_usage_integration.py
@@ -79,5 +79,6 @@ def test_no_summary_works(self):
     target = 'testprojects/src/java/org/pantsbuild/testproject/unicode/main'
     with self.temporary_cachedir() as cachedir, \
       self.temporary_workdir() as workdir:
-      self._run_dep_usage(workdir, target, clean_all=True, cachedir=cachedir,
-        extra_args=['--no-dep-usage-jvm-summary'])
+      for compiler in ['rsc', 'zinc']:
+        self._run_dep_usage(workdir, target, clean_all=True, cachedir=cachedir,
+          extra_args=['--no-dep-usage-jvm-summary', '--jvm-platform-compiler={}'.format(compiler)])