gradle 版本冲突及解决

gradle versions conflict and resolution

我想确定在这种情况下 gradle 依赖项是如何解决的:

$ wget https://github.com/SimpleMobileTools/Simple-Calendar/archive/refs/tags/6.13.7.tar.gz
$ tar -xf 6.13.7.tar.gz
$ cd Simple-Calendar-6.13.7/app
$ ../gradlew dependencies | grep "com.google.code.gson:gson:" | sort -u
     |    +--- com.google.code.gson:gson:2.8.0
     |    |    +--- com.google.code.gson:gson:2.8.5
|    +--- com.google.code.gson:gson:2.8.6
+--- com.google.code.gson:gson:{strictly 2.8.6} -> 2.8.6 (c)

根据文档 here,它说(强调我的)

Maven will take the shortest path to a dependency and use that version

所以在这种情况下 2.8.6 赢了(对吧?)网络输出中是否存在此信息? (--scan

您引用和强调的内容适用于 Maven。在文档中,它为 Gradle 声明了以下内容:

Gradle will consider all requested versions, wherever they appear in the dependency graph. Out of these versions, it will select the highest one.

在您的示例代码段中,GSON 2.8.0 和 2.8.6 之间选择了 2.8.6,因为它是最高版本。此外,似乎有 strict version enforced,因为 strictly 出现在代码段中。