在 gradle 中,我应该排除分支下的所有依赖项还是仅根就足够了?
In gradle, should I exclude all dependencies under a branch or just the root is enough?
我已将以下自定义任务添加到我的 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-base
和 support-v4
和 support-annotations
还是仅 play-services-base
就足够了?
排除 play-services-base
应该足够了。由于您已经排除了父依赖项,因此将不会提供 support-v4
和 support-annotations
,如果没有更多依赖它的话。
如果有更多的依赖,需要support-v4
和support-annotations
用于相同的配置,那么你必须额外排除它们,但它可以为整个配置完成一次。
我已将以下自定义任务添加到我的 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-base
和 support-v4
和 support-annotations
还是仅 play-services-base
就足够了?
排除 play-services-base
应该足够了。由于您已经排除了父依赖项,因此将不会提供 support-v4
和 support-annotations
,如果没有更多依赖它的话。
如果有更多的依赖,需要support-v4
和support-annotations
用于相同的配置,那么你必须额外排除它们,但它可以为整个配置完成一次。