运行maven依赖时如何排除项目内依赖:go-offline

Sah*_*and 10 maven

我有一个多模块项目,我想下载所有依赖项以供离线使用。我使用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
Run Code Online (Sandbox Code Playgroud)

我试图通过运行让 Maven 忽略这个依赖

$ mvn dependency:go-offline -DexcludeArtifactIds=Y
Run Code Online (Sandbox Code Playgroud)

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

Mat*_*ice 2

我在使用 Dockerfile 封装 Maven 构建时遇到了这个问题(如下所示:http ://whitfin.io/speeding-up-maven-docker-builds/ )

到目前为止,我的解决方法是让依赖项获取失败,这在我的 Dockerfile 中如下所示:

RUN mvn -B dependency:go-offline -DexcludeGroupIds=my.company || true
Run Code Online (Sandbox Code Playgroud)

我可以说它不起作用,-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...
Run Code Online (Sandbox Code Playgroud)

下载并缓存了足够的依赖项,稍后我仍然会看到加速,但我更愿意防止错误而不是忽略它。