【问题标题】:Gradle, mavenLocal() and --refresh-dependenciesGradle、mavenLocal() 和 --refresh-dependencies
【发布时间】:2022-01-31 15:28:34
【问题描述】:

在我的 build.gradle 中声明以下内容时:

repositories {
    mavenLocal()
}

我可以将类似的 Maven Artifacts(类似 = 具有完全相同的版本)重新部署到本地 Maven,Gradle 将获取已安装的最新版本,而无需使用 --refresh-dependencies

如果我不是声明 mavenLocal() 存储库,而是声明一个 Maven 远程存储库,那么我必须包含 --refresh-dependencies 才能 100% 确定我获得了最新的已发布版本.这里没问题,这是意料之中的……

但是,我不明白为什么 mavenLocal() 存储库不是这样。我在文档中找不到任何解释:Declaring a changing version

有人有什么提示吗?

【问题讨论】:

    标签: maven gradle repository


    【解决方案1】:

    对本地存储库禁用缓存。

    Declaring repositories 中的The case for mavenLocal() 段落列举了使用mavenLocal() 的各种缺点并解释了您观察到的行为:

    为了减轻元数据和/或工件可以更改的事实,Gradle 不会为 local repositories 执行 any caching

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-08
      • 2023-02-15
      • 2018-07-30
      • 2016-06-15
      • 1970-01-01
      • 2021-05-18
      • 1970-01-01
      • 2019-05-13
      相关资源
      最近更新 更多