gpt4 book ai didi

maven - 使用 Docker 和 Kotlin 缓存 Maven

转载 作者:行者123 更新时间:2023-12-02 12:47:09 26 4
gpt4 key购买 nike

我正在尝试在构建 Kotlin 项目之前预热我的 Docker + Maven 缓存。
正如许多 Maven/Docker 线程所建议的,我的 docker 文件如下所示:

COPY pom.xml .
RUN mvn dependency:go-offline
COPY ./src/ src/
RUN mvn package

我的想法是,如果我更改 ./src 目录中的文件,我希望 docker cache 跳过 maven 冗长的依赖项下载页面。

我的问题是 mvn package命令仍然下载很多文件。
我尝试使用 mvn -o package (maven 离线标志)来诊断缺少哪些依赖项,但它只是提示它无法下载依赖项。但我本来希望在上一步中已经下载了依赖项。以下是我使用“-o”标志得到的错误:
Step 8/13 : RUN  mvn dependency:go-offline
---> Using cache
---> 0334facb9cc9
Step 9/13 : COPY ./src/ src/
---> Using cache
---> 27149a191017
Step 10/13 : RUN mvn -o package
---> Running in 5183eced32ca
Warning: JAVA_HOME environment variable is not set.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building auth 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ auth ---
[WARNING] The POM for org.apache.maven:maven-core:jar:2.0.6 is missing, no dependency information available
[WARNING] The POM for org.apache.maven:maven-monitor:jar:2.0.6 is missing, no dependency information available
[WARNING] The POM for org.codehaus.plexus:plexus-utils:jar:2.0.5 is missing, no dependency information available
[WARNING] The POM for org.apache.maven.shared:maven-filtering:jar:1.1 is missing, no dependency information available
[WARNING] The POM for org.codehaus.plexus:plexus-interpolation:jar:1.13 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.882 s
[INFO] Finished at: 2019-07-12T07:02:23+00:00
[INFO] Final Memory: 13M/174M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources (default-resources) on project auth: Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources failed: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.apache.maven:maven-plugin-api:jar:2.0.6, org.apache.maven:maven-project:jar:2.0.6, org.apache.maven:maven-profile:jar:2.0.6, org.apache.maven:maven-artifact-manager:jar:2.0.6, org.apache.maven:maven-repository-metadata:jar:2.0.6, org.apache.maven:maven-plugin-registry:jar:2.0.6, org.apache.maven:maven-core:jar:2.0.6, org.apache.maven:maven-artifact:jar:2.0.6, org.apache.maven:maven-settings:jar:2.0.6, org.apache.maven:maven-model:jar:2.0.6, org.apache.maven:maven-monitor:jar:2.0.6, classworlds:classworlds:jar:1.1-alpha-2, org.codehaus.plexus:plexus-utils:jar:2.0.5, org.apache.maven.shared:maven-filtering:jar:1.1, org.codehaus.plexus:plexus-interpolation:jar:1.13: Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact org.apache.maven:maven-plugin-api:jar:2.0.6 has not been downloaded from it before. -> [Help 1

最佳答案

尝试遵循 mvn 命令,它使我免于 maven 错误。

RUN  mvn --batch-mode --errors --strict-checksums --threads 1C \
org.apache.maven.plugins:maven-dependency-plugin:3.0.2:go-offline

RUN mvn --batch-mode --errors --offline package

关于maven - 使用 Docker 和 Kotlin 缓存 Maven,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57001765/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com