【问题标题】:What's the different between all*.exclude and all.exclude in configurations.allconfiguration.all 中的 all*.exclude 和 all.exclude 有什么区别
【发布时间】: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


【解决方案1】:

正确的语法是:

使用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。您可以阅读它是如何工作的,以了解它为什么在这里工作。

【讨论】:

    猜你喜欢
    • 2017-09-07
    • 2020-03-18
    • 1970-01-01
    • 2018-02-18
    • 2021-07-25
    • 1970-01-01
    • 1970-01-01
    • 2018-10-12
    • 2014-03-31
    相关资源
    最近更新 更多