Back to Intellij Community

AvoidDuplicateDependencies

plugins/gradle/resources/inspectionDescriptions/AvoidDuplicateDependencies.html

2025.3-rc-21.2 KB
Original Source

Detects duplicate dependency declarations in Gradle build scripts.

Offers an intention to navigate to duplicates and a quick-fix to remove exact matches.

Inspection reporting example:

dependencies {
    implementation("com.google.guava:guava:32.1.2-jre") // will report this line since there is an exact duplicate below
    implementation("com.google.guava:guava:32.1.2-jre") // will report this line since there is an exact duplicate above
    api("com.google.guava:guava:32.1.2-jre") // will also report this line since it's available through another configuration
}

Remove exact duplicates quick-fix example:

dependencies {
    implementation("com.google.guava:guava:32.1.2-jre") // will offer a quick fix
    implementation("com.google.guava:guava:32.1.2-jre") // will offer a quick fix
    api("com.google.guava:guava:32.1.2-jre") // will not offer a quick fix
}

After the quick-fix is applied:

dependencies {
    implementation("com.google.guava:guava:32.1.2-jre")
    api("com.google.guava:guava:32.1.2-jre")
}

Best practice described here.