Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Track added products for cache invalidation
I discovered that in sbt, the scripted tests/internal-tracking test would fail if run with -Dsbt.resident.limit=$NUM where $NUM > 0. This was because the test introduced a dependent project b, that depended on a, but was set to not track a. If the b project was compiled before the a project, the compilation would fail, but a cache entry would be added to the compiler cache with a key that included a's target directory in its classpath. If a was then independently compiled, the expectation would be that b would also compile, but this actually failed. The reason was that when zinc looked for the cached compiler, it found a hit and did not create a new compiler instance. This was a problem because the previous instance was unaware of the newly generated classes from the a project. To get b to compile, it is necessary to invalidate the compiler cache entry. To invalidate the entry, we must detect that there are changes to the project's dependencies. Previously, zinc did not even look at new classes in a dependencies target directory. It did look at removedProducts, but did not actually consider the removed products when constructing the DependencyChanges instance in Incremental.scala. To resolve this, I just append the removed and new products to the binary dependency changes. After this change, `scripted project/internal-tracking` passes even when a global compiler cache is used.
- Loading branch information