Skip to content

Instantly share code, notes, and snippets.

@rock3r
Last active July 19, 2021 18:29
Show Gist options
  • Save rock3r/cf243af5d4e6482f784396b01f04b7ac to your computer and use it in GitHub Desktop.
Save rock3r/cf243af5d4e6482f784396b01f04b7ac to your computer and use it in GitHub Desktop.
Utility Gradle task to find where duplicate classes come from (for Gradle 4.1+)
// H/t to https://github.com/ethankhall/scripts/blob/master/gradle/find-file.gradle for the idea;
// this re-written version actually works in modern Gradle and Android Gradle plugins.
task findInDependencies {
doLast {
println()
def resolvableConfigs = project.getConfigurations()
.stream()
.filter { it.isCanBeResolved() }
resolvableConfigs.each { config ->
config.resolve()
.stream()
.filter {
//noinspection GroovyPointlessBoolean
zipTree(it)
.filter { it.name.startsWith 'Nonnegative' } // TODO replace `Nonnegative` with what you are looking for
.each { println " Match: $it.path" }
.toList()
.isEmpty() == false
}
.each {
println "Found in `$config.name: $it.name`\n"
}
}
}
}
@rock3r
Copy link
Author

rock3r commented Aug 7, 2018

Thanks, I have incorporated it in the main gist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment