简体   繁体   English

当您运行mvn install时会发生什么?

[英]What exactly happens when you run mvn install?

I know that when you run mvn install it will compile, package, and copy the binaries in the local .m2 repository. 我知道,当您运行mvn install ,它将编译,打包和复制本地.m2存储库中的二进制文件。

I recently created a maven project in intelliJ and ran mvn install . 我最近在intelliJ中创建了一个maven项目,并运行了mvn install I then checked the .m2 repository and the generated binaries were there. 然后,我检查了.m2存储库,并且生成的二进制文件在那里。 When I tried to add a dependency to that newly created snapshot from another intelliJ project, they aren't being picked up. 当我尝试从另一个intelliJ项目向该新创建的快照添加依赖项时,它们没有被拾取。

  1. Any idea what is missing? 知道缺少什么吗?
  2. Does anything happen in mvn install besides copying the new snapshot into .m2? 除了将新快照复制到.m2中以外, mvn install是否发生任何事情?

mvn dependency:tree is usually the best tool for figuring out what's going on with dependencies. mvn dependency:tree通常是弄清楚依赖关系到底是什么的最佳工具。

Sometimes with IDE's they use their own repo or don't pick things up. 有时,使用IDE时,他们使用自己的存储库或不收拾东西。 I'd generally do a sanity check mvn clean install from the command line to make sure things are working correctly. 我通常会从命令行执行健全性检查mvn clean install以确保一切正常。

Here is the default lifecycle of maven. 这是Maven的默认生命周期。 When you execute one phase - all previous phases are executed before it. 当执行一个阶段时,所有先前的阶段都将在该阶段之前执行。 So if you call mvn install previous 21 actions will run before install phase which is 22. 因此,如果您致电mvn install先前的21个操作将在install阶段22之前运行。

  1. validate 验证
  2. initialize 初始化
  3. generate-sources 产生源
  4. process-sources 过程源
  5. generate-resources 产生资源
  6. process-resources 流程资源
  7. compile 编译
  8. process-classes 过程类
  9. generate-test-sources 生成测试源
  10. process-test-sources 流程测试源
  11. generate-test-resources 生成测试资源
  12. process-test-resources 流程测试资源
  13. test-compile 测试编译
  14. process-test-classes 过程测试类
  15. test 测试
  16. prepare-package 准备包装
  17. package
  18. pre-integration-test 整合前测试
  19. integration-test 整合测试
  20. post-integration-test 整合后测试
  21. verify 校验
  22. install 安装
  23. deploy 部署

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM