Find which module imported another module

Viewed 111

I need to find out why some module gets included into compilation.

There is some class that should not be included and I think there are some unused imports or bad architecture that requires unnecessary imports. Is there a way to find which modules import some module, which modules import these modules that include this module, and so on, tracking that down to main class of application?

2 Answers

You could use -D dump-dependencies for this, in which case the compiler will generate two files that can be used to follow the dependency graph in both directions:

  • dump/<target>/.dependants.dump
  • dump/<target>/.dependencies.dump

There is also a handy online tool created by Mark Knol that helps a lot with analyzing these files. To answer the question "what does Array depend on?", you can just upload the two files and enter "array" into the search field:

Conveniently, the results are also clickable.

I've just came up with very simple idea: just delete this file and there will be compilation errors in places where this module is imported.

Related