scala - 为什么 sbt 不选择范围内最新的依赖版本?
问题描述
在build.sbt中,我们可以为依赖声明一个范围;例如:
libraryDependencies += groupID %% "mylib" % "[2.0,)"
(在我的情况下)有多个包在这个范围内(我有 2.0.2、2.0.3、2.0.4 甚至一些更奇特的版本,如mylib的 2.0.1.dev 和 2.0.3-dev可用我的存储库)。
当我尝试构建这个项目时,无缘无故地sbt
选择了2.0.2版本。我希望他能在这个范围内取最大的数字,但他从来没有。以下是我尝试过的要求和他选择的版本(因此只有在指定确切的版本号时,他才会选择更新的版本):
revision range | version selected
-----------------------------------------
[2.0,) | 2.0.2
[2.0.0,) | 2.0.2
]2.0,) | 2.0.2
2.0.+ | 2.0.2
latest.integration | 2.0.2
2.0.3 | 2.0.3
2.0.4 | 2.0.4
我已经尝试了以下解决方法:
- 删除本地~/.sbt和~/.ivy2目录
- 运行
sbt -no-share -sbt-dir /tmp/sbt -ivy-dir /tmp/ivy
以避免任何缓存效果 - 在我的主目录中搜索名称中包含mylib的任何文件;只找到 ind ~/.ivy2
- 我已经使用sbt 0.13.16运行了大部分测试,但我尝试使用 0.13.15 和 0.13.17
- 请注意,我的所有构建每次都在我的 git 存储库的干净克隆中运行;所以没有目标目录。
- mylib 的 2.0.2、2.0.3 和 2.0.4 版本包含相同的代码和依赖项(出于测试目的,我重新发布了它们)
解决方案
问题(一次)似乎并不存在于sbt
.
我尝试使用sbt 1.2.1和 range 2.1.x
。现在 sbt 抱怨他找不到这个依赖;他列出了可用的版本:
[warn] ==== my-maven-repo: tried
[warn] http://my-server/nexus/repository/my-repo/eu/company/mylib_2.12/[revision]/mylib_2.12-[revision].pom
[warn] [2.0.2, 2.0.2-dev.20180719.16.55.39.develop.dc3a706, 2.0.1-dev.20180719.16.49.57.develop.dc3a706, 2.0.1-dev.20180719.16.42.31.develop.dc3a706, 2.0.1.dev.20180719.16.31.59.develop.dc3a706]
奇怪的是,他没有列出我的 nexus-maven 存储库中可用的所有软件包。使用nexus接口删除一个包后;看起来这个列表现在已经完成了。
所以真正的问题似乎是sbt publish
一个关系存储库不会在该存储库中重新创建索引。
解决方法
我创建了一个自定义sbt-publish-wrapper脚本来强制nexus
在发布新库时重新创建存储库元数据:
#!/bin/bash
set -e
# just run sbt publish with the passed arguments as-is
sbt $@ publish
# now make sure the repository on nexus is re-indexed
# this triggers a task to recreate metadata for all maven repositories. This task was manually configured in nexus.
# the id was obtained running `curl -v -u admin:***** -X GET http://my-company/nexus/service/rest/v1/tasks`
# the recreate-maven-repos needs only the nx-tasks-run privilege
curl -q -u recreate-maven-repos:recreate -X POST http://my-company/nexus/service/rest/v1/tasks/c42ab5f5-4bd6-4ed3-b2f1-d061c24a9b90/run
推荐阅读
- php - $this[$variable] 在 php 中是什么意思?
- sql - Oracle SQL 开发人员上的 Oracle 11g 连接失败
- android - ExoPlayer r1.5.12 到 2.7.3 的迁移
- python - Pandas to_datetime 在非美国日期的行为不一致
- javascript - For循环获取var1,var2,var3 ...动态使用var + i?
- node.js - React+Express:尝试使用 fetch 抓取数据时出现错误 ECONNREFUSED
- gradle - 如何排除 Gradle 的 jar.from 中的文件?
- r - 使用 fill 有条件地填充 NA 值而无需循环
- python - python中的字母猜谜游戏,不能替换字母
- powershell - Powershell 错误地从 REST API 解析 JSON