【问题标题】:In gradle, should I exclude all dependencies under a branch or just the root is enough?在 gradle 中,我应该排除分支下的所有依赖项还是仅根目录就足够了?
【发布时间】:2015-10-25 19:12:46
【问题描述】:

我已将以下自定义任务添加到我的 build.gradle 文件中,以便打印出依赖项的依赖项。

// This part is useful for finding conflict resolution(s) between dependencies in order to exclude them.
// You can change the custom value and run following command in terminal:
// ./gradlew passenger-sdk:dependencies --configuration custom
configurations {
    custom
}

dependencies {
    custom 'com.google.android.gms:play-services-analytics:7.3.0'
}

所以结果是:

$ ./gradlew passenger-sdk:dependencies --configuration custom
:passenger-sdk:dependencies

------------------------------------------------------------
Project :passenger-sdk
------------------------------------------------------------

custom
\--- com.google.android.gms:play-services-analytics:7.3.0
     \--- com.google.android.gms:play-services-base:7.3.0
          \--- com.android.support:support-v4:22.0.0
               \--- com.android.support:support-annotations:22.0.0

BUILD SUCCESSFUL

Total time: 1.681 secs

我想排除它的所有依赖项,因为我有它们。我应该排除所有三个依赖项play-services-basesupport-v4support-annotations 还是仅仅play-services-base 就足够了?

【问题讨论】:

    标签: android android-gradle-plugin build.gradle


    【解决方案1】:

    排除play-services-base 就足够了。由于您已排除父依赖项,因此不会提供 support-v4support-annotations,如果没有其他依赖项的话。

    如果有更多的依赖项,需要support-v4support-annotations用于相同的配置,那么您必须额外排除它们,但可以为整个配置完成一次。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-07
      • 2014-05-26
      • 1970-01-01
      • 1970-01-01
      • 2021-12-03
      • 2018-11-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多