Cleanup
As time goes on, we add some libraries. As time goes on and on, we update code and stop using some libraries. Then our dependencies are becoming messy, because we include more libraries than we need.
Preview dependency tree
Lets say we have multi module project that consists from the following modules.
.
├── app
├── core
├── db
├── build.gradle
├── README.mdThe app module, which is a directory, contains runnable application and we want to see all dependencies in all the configurations. We can do the following to dependencies for all classpaths (or better said, configurations of classpaths).
gradle :app:dependenciesWhen we are dealing with bigger project, we might want to get dependency for a specific classpath configuration. For example, the application is running fine, but when we run tests, something does not compile. In that case, we want to check testCompile configuration.
gradle :app:dependencies --configuration testCompileOr if everything compiles fine, but tests are failing in runtime, we might want to check testRuntime configuration.
gradle :app:dependencies --configuration testRuntimeClasspathGradle Lint
We can use Gradle lint plugin by Netflix to cleanup dependencies in our Gradle project.
We need to apply the lint plugin and then define rules for the plugin. It is always to go with all-dependency rule.
When we run the build, we will get report. It can look like this.
First we can try to do the automatic cleanup.
Now we need to go to Gradle build file and do the cleanup manually.
Last updated
Was this helpful?