SBT 中未解决的依赖关系:未找到 ivy 文件

Unresolved dependency in SBT: no ivy file found

我有一个 SBT 项目,它使用内部 Nexus 存储库来获取它的一些依赖项。当我 运行 update 时,我看到以下警告消息:

[info] Resolving foo.bar.baz#foobar;2.0.1
...
[debug]     The Repo of Interest: no ivy file found for foo.bar.baz#foobar;2.0.1
[warn]  module not found: foo.bar.baz#foobar;2.0.1
[warn] ==== local: tried
...
... several irrelevant repositories omitted...
...
[warn] ==== The Repo of Interest: tried
[warn]   http://internal.url.com/nexus/content/repositories/releases/foo/bar/baz/foobar/2.0.1/foobar-2.0.1.pom
...
... some other repositories omitted...
...

上面显示的 URL 似乎应该可以工作,因为我可以在我的浏览器中打开 pom 而不会出现问题(请注意,我已经修改了 URL 所以你必须接受我的它有效的词)。 更令人困惑的是,我只在某些机器上尝试构建时才看到这个问题。我该如何开始调试这个问题?是否有我可以打开的任何其他日志记录,以了解为什么 SBT/Ivy 忽略位于上述 URL 的 POM?

更新:我的 build.sbt 定义解析器如下:

resolvers := Seq(
  ...,
  "The Repo of Interest" at "http://internal.url.com/nexus/content/repositories/releases",
  ...
)

http://internal.url.com/nexus/content/repositories/releases/foo/bar/baz/foobar/2.0.1 文件夹还包含所有这些文件的 pom、jar、源 jar 和相关的 md5 和 sha1。 pom 文件如下所示:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>foo.bar.baz</groupId>
  <artifactId>foobar</artifactId>
  <version>2.0.1</version>
  <dependencies>
    ...
  </dependencies>
</project>

更新 #2:构建似乎只能在其他机器上运行,因为它们已经在 ~/.ivy2/cache/foo/bar/baz/foobar/jars.

下缓存了相关 jar 的副本

更新 #3:仔细查看日志后,我相信 The Repo of Interest: no ivy file found for foo.bar.baz#foobar;2.0.1 是真正的错误消息

确保网络上的所有计算机都可以访问nexus 服务器。也尝试强制更新您的回购协议。过去,我 运行 遇到过以下问题:nexus 文件夹中有一个 pom 文件,但没有关联的 jar 文件,因此请检查以确保存在与 pom

关联的工件

谢谢大家的建议!事实证明,在我的特定情况下,答案非常简单:存储库 URL 需要以 https 而不是 http 开头。在尝试使用 Coursier's command line tool 通过以下命令手动获取 jar 后,我偶然发现了这个解决方案:

coursier fetch -r http://internal.url.com/nexus/content/repositories/releases foo.bar.baz:foobar:2.0.1

然后生成如下所示的输出:

Error:
  foo.bar.baz:foobar:2.0.1
    not found: /some/path/.ivy2/local/foo.bar.baz/foobar/2.0.1/ivys/ivy.xml
    not found: https://repo1.maven.org/maven2/foo/bar/baz/foobar/2.0.1/foobar-2.0.1.pom
    checksum format error: ...

没有 not found: http://internal.url.com/nexus/content/repositories/releases... 行似乎很奇怪,我只是碰巧认为也许 URL 实际上应该以 https.

开头

我使用 sbt update 修复了它,然后 publish 立即修复了它。参考:https://github.com/sbt/sbt/issues/3496