【发布时间】:2019-12-21 16:17:34
【问题描述】:
当你想排除依赖项时,我想知道配置中的 all*.exclude 和 all.exclude 有什么不同
configurations.all {
all.exclude
all*.exclude group: 'org.json', module: 'json'
}
【问题讨论】:
标签: gradle android-gradle-plugin build.gradle gradlew
当你想排除依赖项时,我想知道配置中的 all*.exclude 和 all.exclude 有什么不同
configurations.all {
all.exclude
all*.exclude group: 'org.json', module: 'json'
}
【问题讨论】:
标签: gradle android-gradle-plugin build.gradle gradlew
正确的语法是:
all 方法configurations.all {
exclude group: 'org.json', module: 'json'
}
或
all 属性configurations {
all*.exclude(group: 'org.json', module: 'json')
}
all 属性包含项目configurations 中所有configuration 对象的列表。
如果您想查看它实际包含的内容,您可以这样做:
println configurations.all.names
或
println configurations.all*.name
语法*. 是一个特定于groovy 的运算符,称为spread operator。您可以阅读它是如何工作的,以了解它为什么在这里工作。
【讨论】: