is there a way to find unused dependencies when us...
# community-support
p
is there a way to find unused dependencies when using Kotlin DSL? I see that gradle-lint-plugin supports only Groovy
👀 1
v
The https://github.com/autonomousapps/dependency-analysis-gradle-plugin is quite good - except for some edge cases - in telling you which dependency belongs to what scope or is unused.
thank you 2
👀 1
❀ 1
p
I see it's reporting some false positives (in my opinion) when I use a convention plugin that declares some dependencies, and then the module depending on this plugin doesn't use some of the dependencies. I'll try to tinker with the configuration, maybe it can be set to ignore such cases
a
I cannot recommend the Dependency Analysis Gradle Plugin that @Vampire shared enough! We recently deployed this to ~20 repos and it caught hundreds of ABI issues! One recommendation I'd suggest is to hook the buildHealth task into your CI so you can have automated gating to prevent dependency regressions.
and yeah you can add rules to the plugin extension to exclude cases where necessary
v
I usually even wire
buildHealth
to
check
, not only CI. 🙂
Which false-positives you have, you would need to tell. If they are for example the ones that you depend on
<plugin id>:<plugin id>.gradle.plugin:<plugin version>
instead of on the actual code artifact, but then use the classes from the code artifact, the plugin is basically right in complaining, as you use classes from a transitive dependency which generally is bad practice. But in cases like this where this is exactly intended, that you depend on one artifact but use classes from its dependency, you can declare bundles for the plugin to know that like
Copy code
dependencyAnalysis {
    dependencies {
        bundle("com.autonomousapps.dependency-analysis.gradle.plugin") {
            includeDependency("com.autonomousapps.dependency-analysis:com.autonomousapps.dependency-analysis.gradle.plugin")
            includeDependency("com.autonomousapps:dependency-analysis-gradle-plugin")
        }
    }
}