In gradle, should I exclude all dependencies under

2019-05-11 19:42发布

问题:

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.