Gradle 查看错误的 Maven 存储库
Gradle look into wrong maven repository
当我同步我的 Android 项目时,我不断看到以下消息:
Gradle: Download https://s3.amazonaws.com/moat-sdk-builds/com/google/android/gms/play-services-ads-base/maven-metadata.xml
Gradle: Download https://s3.amazonaws.com/moat-sdk-builds/com/google/android/gms/play-services-measurement-base/maven-metadata.xml
Gradle: Download https://s3.amazonaws.com/moat-sdk-builds/com/google/firebase/firebase-iid/maven-metadata.xml
这些库应该可以在 google()
repo 中找到,这是我设置中的第一个:
allprojects {
repositories {
google()
jcenter()
// ...
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
}
}
然而,它查看maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
并浪费了很多时间。这里发生了什么?有什么办法可以调试吗?谢谢。
你可以试试customize dependency resolution behaviour or declare repository filters.
声明存储库过滤器就这么简单:
allprojects {
repositories {
google()
jcenter()
// ...
maven {
url "https://s3.amazonaws.com/moat-sdk-builds"
content {
// Does only include this group
includeGroup "moat.sdk"
}
}
}
}
还可以选择 exclude
组并增强构建性能等。
请注意 "Matching repositories to dependencies is an incubating feature." API documentation 提供了有关过滤器选项的更多信息。
您可以在下面找到有关您遇到的具体行为的更多信息。当涉及到依赖项解析时,Gradle 会按顺序检查存储库。
How dependency resolution works
[...]
- Given a required dependency, Gradle attempts to resolve the dependency by searching for the module the dependency points at. Each repository is inspected in order. Depending on the type of repository, Gradle looks for metadata files describing the module (.module, .pom or ivy.xml file) or directly for artifact files.
[...]
但据我了解 gradle 'visits' 每个存储库,无论它是否已经找到 'correct' 工件。
- Once each repository has been inspected for the module, Gradle will choose the 'best' one to use. This is done using the following criteria:
- For a dynamic version, a 'higher' concrete version is preferred over a 'lower' version.
- Modules declared by a module metadata file (.module, .pom or ivy.xml file) are preferred over modules that have an artifact file only.
- Modules from earlier repositories are preferred over modules in later repositories.
- When the dependency is declared by a concrete version and a module metadata file is found in a repository, there is no need to continue searching later repositories and the remainder of the process is short-circuited.
[...]
Introduction to Dependency Management - How dependency resolution works
当我同步我的 Android 项目时,我不断看到以下消息:
Gradle: Download https://s3.amazonaws.com/moat-sdk-builds/com/google/android/gms/play-services-ads-base/maven-metadata.xml
Gradle: Download https://s3.amazonaws.com/moat-sdk-builds/com/google/android/gms/play-services-measurement-base/maven-metadata.xml
Gradle: Download https://s3.amazonaws.com/moat-sdk-builds/com/google/firebase/firebase-iid/maven-metadata.xml
这些库应该可以在 google()
repo 中找到,这是我设置中的第一个:
allprojects {
repositories {
google()
jcenter()
// ...
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
}
}
然而,它查看maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
并浪费了很多时间。这里发生了什么?有什么办法可以调试吗?谢谢。
你可以试试customize dependency resolution behaviour or declare repository filters.
声明存储库过滤器就这么简单:
allprojects {
repositories {
google()
jcenter()
// ...
maven {
url "https://s3.amazonaws.com/moat-sdk-builds"
content {
// Does only include this group
includeGroup "moat.sdk"
}
}
}
}
还可以选择 exclude
组并增强构建性能等。
请注意 "Matching repositories to dependencies is an incubating feature." API documentation 提供了有关过滤器选项的更多信息。
您可以在下面找到有关您遇到的具体行为的更多信息。当涉及到依赖项解析时,Gradle 会按顺序检查存储库。
How dependency resolution works
[...]
- Given a required dependency, Gradle attempts to resolve the dependency by searching for the module the dependency points at. Each repository is inspected in order. Depending on the type of repository, Gradle looks for metadata files describing the module (.module, .pom or ivy.xml file) or directly for artifact files.
[...]
但据我了解 gradle 'visits' 每个存储库,无论它是否已经找到 'correct' 工件。
- Once each repository has been inspected for the module, Gradle will choose the 'best' one to use. This is done using the following criteria:
- For a dynamic version, a 'higher' concrete version is preferred over a 'lower' version.
- Modules declared by a module metadata file (.module, .pom or ivy.xml file) are preferred over modules that have an artifact file only.
- Modules from earlier repositories are preferred over modules in later repositories.
- When the dependency is declared by a concrete version and a module metadata file is found in a repository, there is no need to continue searching later repositories and the remainder of the process is short-circuited.
[...]
Introduction to Dependency Management - How dependency resolution works