如何在运行maven依赖项时排除项目内部的依赖项:脱机

问题描述 投票:2回答:1

我有一个多模块项目,我想在其中下载所有依赖项以供脱机使用。我使用mvn dependency:go-offline目标进行此操作。在项目中,有一个模块X依赖于另一个模块Y。由于dependency:go-offline命令没有构建模块,因此在构建X时会出现一个错误,即找不到依赖项Y:

$ mvn dependency:go-offline -Dmaven.artifact.threads=30

 Failure to find se.cust.id:Y:jar:1.2.3-SNAPSHOT in https://mvn.com.com/repository/com-snapshots/ was cached in the local repository, resolution will not be reattempted until the update interval of com-snapshots has elapsed or updates are forced

我试图通过运行使Maven忽略此依赖性

$ mvn dependency:go-offline -DexcludeArtifactIds=Y

但是这会导致相同的错误。在这里排除依赖项的正确方法是什么?

maven
1个回答
0
投票

[我在用Dockerfile封装Maven构建时遇到了问题(例如:http://whitfin.io/speeding-up-maven-docker-builds/

到目前为止,我的解决方法是让依赖项获取失败,在我的Dockerfile中看起来像这样:

RUN mvn -B dependency:go-offline -DexcludeGroupIds=my.company || true

我可以知道-DexcludeGroupIds无效,因为出现错误:

Failure to find my.company:subproject-built-here:jar:1-SNAPSHOT in http://packages.confluent.io/maven/ was cached in the local repository, resolution will not be reattempted until...

已经下载并缓存了足够多的依赖项,以后我仍然会看到速度提高,但是我宁愿防止错误而不是忽略它。

© www.soinside.com 2019 - 2024. All rights reserved.