在gradle中,我应该排除分支下的所有依赖项还是仅仅根目录就足够了?

时间:2015-10-25 19:12:46

标签: android android-gradle build.gradle

我已将自定义任务添加到我的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-v4以及support-annotations或仅play-services-base就足够了?

1 个答案:

答案 0 :(得分:0)

排除play-services-base就足够了。由于您已排除了父依赖关系,因此不会提供support-v4support-annotations,如果没有更多依赖于它。

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