Implement zinc `unused deps` check

Review Request #3635 - Created March 31, 2016 and submitted

Stu Hood
benjyw, gmalmquist, nhoward_tw, peiyu

This is an implementation of an "unused deps" check for zinc. See for more information.

  • Add a forced scope to indicate that a particular target is in the default scope, but is not eligible for unused dep checks.
  • Separate JvmDependencyAnalyzer out of the Task hierarchy into a standalone class.
  • Implement the check and return a dict of suggested (ie, more specific) replacements.
  • Move strict/non-strict dep calculation into CompileContext.
  • Remove spurious deps in the examples code.
  • Remove strict_deps=False in a few places where scope=forced on a particular dep would be preferable.
  • Formalize JavacPlugin's tools.jar dep as an injected target provided by a task during bootstrap.
  • In case of an unused dep (which is eligible to be marked that way due to its scope), declare the dependency_type of the edge unused in the dep-usage.jvm task.

This review also cleans up all warnings/errors for:

./pants compile.zinc --unused-deps=fatal examples/{src,tests}/{java,scala}/::

When an unused dep is encountered, it is logged like so:

compile(examples/tests/scala/org/pantsbuild/example/hello/welcome:welcome) failed: unused dependencies:
Suggested replacements:
(If you're seeing this message in error, you might need to change the `scope` of the dependencies.)

... with suggested replacements coming from the transitive deps of the unused deps that were used.


  • 0
  • 3
  • 1
  • 4
Description From Last Updated
Stu Hood
Garrett Malmquist
Stu Hood
Stu Hood
Stu Hood
Stu Hood
Garrett Malmquist
Stu Hood
Stu Hood
Benjy Weinberger
Stu Hood
Peiyu Wang
Stu Hood
Review request changed

Status: Closed (submitted)

Change Summary:

Merged as 5b7d317160b69e4ec0077cbfc2380e6df8217717