autonomousapps / dependency-analysis-gradle-plugin

Gradle plugin for JVM projects written in Java, Kotlin, Groovy, or Scala; and Android projects written in Java or Kotlin. Provides advice for managing dependencies and other applied plugins
Apache License 2.0
1.66k stars 116 forks source link

Provide modularization advice based on dependency information #1208

Open alllex opened 6 days ago

alllex commented 6 days ago

Is your feature request related to a problem? Please describe.

In larger projects, it often happens that certain modules accumulate classes that are not necessarily tied into a coherent group. Rather, classes may be added to such a module only because many other modules already depend on it, and it makes it easier to "expose" the new class to the desired dependants. Or such "bloated" modules exist in the build for historical reasons.

Modularization (splitting larger modules into smaller ones) can have many benefits, such as better compilation times and more cache hits during the build process. However, often times it is not trivial with where to start that modularization process.

The dependency analysis on the class level may contain enough information to find places where the build structure is ready or almost ready for some modules to be split.

Describe the solution you'd like

The plugin provides a new task. The task is responsible for finding classes that, when moved to another module, would allow the dependencies of their dependents to be "lighter."

For instance, if many modules depend only on a few classes from a large module M, then when these few classes are moved to another module S, the dependencies of those many modules could be changed to just depend on S instead of the whole M.

Describe alternatives you've considered

Additional context