Nexus/Gradle 锁定特定版本

Nexus/Gradle lock specifc versions

我们正在使用 gradle 作为构建工具和 sonatype nexus 来存储项目第三方和 public 工件。

最近更新了一个 public 工件 com.abc:cde:3.4.2,其中我们的项目使用 com.abc:cde:3.4.1

然而,在构建执行期间,gradle 拉取了最新版本的工件,即使构建被明确指定为仅下载 3.4.1

compile 'com.abc:cde:3.4.1'

有没有办法只下载特定版本的依赖项,即使 nexus 具有最新版本的工件

您可以通过对配置使用解析策略来强制使用版本号。

例如

configurations.compile {
  resolutionStrategy {
      force 'com.abc:cde:3.4.1'
  }
}

查看 https://docs.gradle.org/current/dsl/org.gradle.api.artifacts.ResolutionStrategy.html 了解更多信息。