gradle 是否可以使用优先级高于 jcenter 的 maven 存储库
Is gradle possible to use maven repository with higher priority than jcenter
Gradle 可以设置多个仓库,例如行家和jcenter。但是我意识到 gradle 总是先使用 jcenter,即使我将 maven 放在 jcenter 之前(如下所示)。是否可以使 maven(本地回购,更快)具有更高的优先级?
## in file build.gradle
allprojects {
repositories {
maven { url "http://nexus.mucompany.com/nexus/service/local/repositories/releases/content/" }
jcenter()
}
我想问这个作为评论,但还没有得到足够的代表:-/
你能post gradle --debug
的输出让你认为它优先从 jcenter 解析吗?
gradle docs 包含以下内容:
A project can have multiple repositories. Gradle will look for a dependency in each repository in the order they are specified, stopping at the first repository that contains the requested module.
本地的快速确认显示自定义 Maven 存储库和 jcenter()
之间的订单得到遵守
撇开事实不谈,至少在较新的 gradle 版本中顺序很重要:
It’s even more important when considering that order of repositories matter.
…
✨ The order of declaration determines how Gradle will check for dependencies at runtime. If Gradle finds a module descriptor in a particular repository, it will attempt to download all of the artifacts for that module from the same repository. You can learn more about the inner workings of Gradle’s resolution mechanism.
来源:gradle 5.4.1 Declaring multiple repositories
或者这是您特定 gradle 版本中的错误 - 我的答案可能会在 "a bit late" 那天 2k19 出现,因为您的问题来自 '15 ;D
(至少在Gradle 3.5 中定义类似
A project can have multiple repositories. Gradle will look for a dependency in each repository in the order they are specified, stopping at the first repository that contains the requested module.
来源:gradle 3.5 Dependency Management for Java Projects
)
一个常见问题 是,更高优先级的存储库和/或本地缓存已损坏!
通常,人工制品 jcenter 代理包含不情愿的 POM 声明,但没有 jars。然后你必须清理人工制品。
类似于本地存储库。
您可以尝试通过 运行 gradle 忽略本地缓存并启用 --refresh-dependencies
和最佳情况 -i
日志记录以查看请求去向和结果.
看看How can I force gradle to redownload dependencies?
第二个选项:
as of gradle 5.1 您可以随时声明过滤器
参见 gradle 5.4.1 Declaring a repository filter
对我来说,我忽略了来自 jcenter 的任何 com.android 包,这样可以加快搜索速度并减少上述已知问题
Gradle 可以设置多个仓库,例如行家和jcenter。但是我意识到 gradle 总是先使用 jcenter,即使我将 maven 放在 jcenter 之前(如下所示)。是否可以使 maven(本地回购,更快)具有更高的优先级?
## in file build.gradle
allprojects {
repositories {
maven { url "http://nexus.mucompany.com/nexus/service/local/repositories/releases/content/" }
jcenter()
}
我想问这个作为评论,但还没有得到足够的代表:-/
你能post gradle --debug
的输出让你认为它优先从 jcenter 解析吗?
gradle docs 包含以下内容:
A project can have multiple repositories. Gradle will look for a dependency in each repository in the order they are specified, stopping at the first repository that contains the requested module.
本地的快速确认显示自定义 Maven 存储库和 jcenter()
撇开事实不谈,至少在较新的 gradle 版本中顺序很重要:
It’s even more important when considering that order of repositories matter.
…
✨ The order of declaration determines how Gradle will check for dependencies at runtime. If Gradle finds a module descriptor in a particular repository, it will attempt to download all of the artifacts for that module from the same repository. You can learn more about the inner workings of Gradle’s resolution mechanism.
来源:gradle 5.4.1 Declaring multiple repositories
或者这是您特定 gradle 版本中的错误 - 我的答案可能会在 "a bit late" 那天 2k19 出现,因为您的问题来自 '15 ;D
(至少在Gradle 3.5 中定义类似
A project can have multiple repositories. Gradle will look for a dependency in each repository in the order they are specified, stopping at the first repository that contains the requested module.
来源:gradle 3.5 Dependency Management for Java Projects )
一个常见问题 是,更高优先级的存储库和/或本地缓存已损坏! 通常,人工制品 jcenter 代理包含不情愿的 POM 声明,但没有 jars。然后你必须清理人工制品。 类似于本地存储库。
您可以尝试通过 运行 gradle 忽略本地缓存并启用 --refresh-dependencies
和最佳情况 -i
日志记录以查看请求去向和结果.
看看How can I force gradle to redownload dependencies?
第二个选项: as of gradle 5.1 您可以随时声明过滤器
参见 gradle 5.4.1 Declaring a repository filter
对我来说,我忽略了来自 jcenter 的任何 com.android 包,这样可以加快搜索速度并减少上述已知问题