![](/img/trans.png)
[英]How to migrate protect level build.gradle file from Gradle Groovy to Gradle Kotlin DSL
[英]How to exclude library from all dependencies in Kotlin DSL build.gradle?
我開始從build.gradle
(Groovy) 遷移到build.gradle.kts
(Kotlin DSL)。 問題是com.google.common.util.concurrent.ListenableFuture
(來自com.google.guava
)存在於幾個依賴項中。 由於該構建失敗, java.lang.RuntimeException: Duplicate class...
錯誤。
以前(當我在 Groovy 中有build.gradle
時)這個問題是用這個片段解決的:
configurations {
all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}
但我無法使用 Kotlin DSL 找到任何類似的東西。 您能否為上面的代碼片段提供 Kotlin 替代方案,或者就如何處理此問題提出任何其他解決方案?
這適用於 Gradle Kotlin DSL:
configurations {
all {
exclude(group = "com.google.guava", module = "listenablefuture")
}
}
這可能有效(雖然我還沒有嘗試過):
configurations.forEach { it.exclude("com.google.guava", "listenablefuture") }
對於兩組,您可以這樣使用:
configurations.forEach {
it.exclude("com.google.guava", "listenablefuture")
it.exclude(group = "org.jetbrains", module = "annotations")
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.