In gradle, should I exclude all dependencies under a branch or just the root is enough?

牧云@^-^@ 提交于 2020-01-02 08:38:11

问题


I've added following custom task into my build.gradle file In order to print out dependencies of a dependency.

// 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'
}

So the result is:

$ ./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

I want to exclude all of its dependencies since I have them. Should I exclude all three dependencies play-services-base and support-v4 and support-annotations or just play-services-base is enough?


回答1:


Exclude play-services-base should be enough. Since you've excluded the parent dependency, support-v4 and support-annotations will not be provided, if nothing more depends on it.

If there are some more dependencies, which need to have support-v4 and support-annotations for the same configuration, then you have to exclude them additionally, but it could be done once for whole configuration.



来源:https://stackoverflow.com/questions/33333896/in-gradle-should-i-exclude-all-dependencies-under-a-branch-or-just-the-root-is

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!