Maven downloads all dependencies again because they were "cached from a remote repository ID that is unavailable in current build context"

huangapple go评论98阅读模式
英文:

Maven downloads all dependencies again because they were "cached from a remote repository ID that is unavailable in current build context"

问题

在第一步,我下载并缓存所有依赖项(我使用Maven目标package来执行此操作)。这个Docker层是未来所有构建步骤的基础。

在第二步,我构建项目。

然而,在第二步中,所有依赖项都会再次被下载。我通过使用dive确保在Maven存储库中已经存在这些依赖项,并且使用了正确的Maven存储库。

当我以调试模式运行Maven,通过传递-X参数,我在每次重新下载依赖项之前都会收到以下警告:

"Artifact XYZ is present in the local repository, but cached from a remote repository ID that is unavailable in current build context, verifying that is downloadable from XYZ"

这是打印该警告的Maven源代码位置。

我该如何解决这个警告?如何防止Maven重新下载依赖项?

英文:

I have a multi-staged Docker build.

In step one, I download and cache all dependencies (I use the Maven goal package for this). This is Docker layer is the base for all future build steps.

In step two, I build the project.

However, in step two, all dependencies get downloaded again. I made sure by using dive that the dependencies already exist in the Maven repository before and that the correct Maven repository is used.

When I run Maven in debugging mode by passing -X, I get this warning before each dependency is downloaded again:

> Artifact XYZ is present in the local repository, but cached from a
> remote repository ID that is unavailable in current build context,
> verifying that is downloadable from XYZ

Here is the Maven source code where it is printed.

How can I solve this warning? How to keep Maven from downloading the dependencies again?

答案1

得分: 0

问题在于我以为dependency:resolve也会下载所有依赖项。但事实并非如此。

英文:

The problem was that I thought dependency:resolve also downloads all dependencies. But that's not what it does.

huangapple
  • 本文由 发表于 2023年5月29日 16:33:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76355794.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定