Reputation: 5635
I started migration from build.gradle
(Groovy) to build.gradle.kts
(Kotlin DSL). The thing is that com.google.common.util.concurrent.ListenableFuture
(from com.google.guava
) exists in several dependecies. Because of that build fails with java.lang.RuntimeException: Duplicate class ...
error.
Previously (when I had build.gradle
in Groovy) this problem was solved with this snippet:
configurations {
all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}
But I can't find anything similar using Kotlin DSL. Could you please provide Kotlin alternative for the snippet above or suggest any other solution on how to deal with this?
Upvotes: 36
Views: 31513
Reputation: 7220
For two group you can use like this:
configurations.forEach {
it.exclude("com.google.guava", "listenablefuture")
it.exclude(group = "org.jetbrains", module = "annotations")
}
Upvotes: 2
Reputation: 4246
This works with the Gradle Kotlin DSL:
configurations {
all {
exclude(group = "com.google.guava", module = "listenablefuture")
}
}
Upvotes: 75
Reputation: 7026
This might work (though I haven't tried it):
configurations.forEach { it.exclude("com.google.guava", "listenablefuture") }
Upvotes: 17