'mvn clean install':为什么 'clean' 运行 在 'install' 之后?

'mvn clean install': why does 'clean' run after 'install'?

如果我运行 mvn clean install 为什么 maven 在安装后进行清理?

我问的原因是因为我想在 jenkins 调用 maven 后从工作区获取生成的 EAR,而不是 repo 位置

这是控制台输出的一部分:

[INFO] --- maven-install-plugin:2.4:install (default-install) @ myProject.EAR ---
[INFO] Installing target/myProject.EAR-1.0.0.ear to /var/lib/jenkins/.m2/repository/uk/co/mycompany/myProject.EAR/1.0.0/myProject.EAR-1.0.0.ear
[INFO] Installing /var/lib/jenkins/jobs/MP/workspace/myProject.EAR/pom.xml to /var/lib/jenkins/.m2/repository/uk/co/mycompany/myProject.EAR/1.0.0/myProject.EAR-1.0.0.pom
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building myProject 20.5.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ myProject ---
[INFO] Deleting /var/lib/jenkins/jobs/MP/workspace/myProject/target
[INFO] 

当您 运行 mvn clean install 时,它针对每个模块执行,即父项目和每个子模块。您的日志摘录显示它完成了 myProject.EAR 项目的 install 部分,并开始处理 myProject,从 clean 开始打印 (default-clean) @ myProject

从日志中的路径也可以看出这一点:第一个模块位于/var/lib/jenkins/jobs/MP/workspace/myProject.EAR,而第二个模块位于/var/lib/jenkins/jobs/MP/workspace/myProject

也许您可以描述您在做什么以及什么不起作用,但这部分构建似乎按设计工作。