"Maven Install"和"Maven Install"之间有什么区别?和"Maven Build"使用M2Eclipse? [英] What is the difference between "Maven Install" and "Maven Build" with M2Eclipse?

查看:245
本文介绍了"Maven Install"和"Maven Install"之间有什么区别?和"Maven Build"使用M2Eclipse?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在eclipse m2e插件中搜索maven安装和maven构建之间的区别(如果右键单击该项目并单击运行方式",您将看到它们),但我仍然找不到很好的解释他们(我也浏览了官方文件) .有人可以帮忙吗?据我目前的了解:

I tried to search about the differences between maven install and maven build in the eclipse m2e plugin (if you right click the project and click "run as", you will see them), and I still cannot find a good explanation of them (I looked through the official document as well). Anyone can help? From what I currently understand:

  • maven安装:将工件构建并安装到本地存储库
  • maven构建:仅构建但不安装?那么安装意味着什么?

此外,当您在线签出存储库时,通常是否要进行maven安装(安装所有程序,包括依赖项)以运行代码?

Also, when you checkout a repository online, do you usually do maven install (to install everything, including the dependencies) in order to run the code?

推荐答案

首先,build

First of all, build is not a phase in the standard Maven lifecycles, whereas install is one. mvn install will invoke all the phases up to the phase install, which generally consists of compiling the source code, packaging the project and installing it in the local repository.

为清楚起见,我们正在谈论M2Eclipse在运行方式"选择中显示的内容.

To be clear, we're talking about what M2Eclipse shows in the "Run As" selection.

所有这些选项是什么?首先,您需要知道可以:

What are all those options? First of all, you need to be aware that you can:

通过转到:

这将打开一个对话框,您可以在其中配置那些自定义配置.

This will open a dialog where you can configure those custom configurations.

您可以通过以下方式创建新的"Maven Build"运行配置:

You can create a new "Maven Build" run configuration, by giving it:

  • 名称:这将是配置的唯一名称.您可以随意命名.在上面,它使用将要调用的目标来命名.
  • 基本目录:这是将在其中调用Maven的文件夹.在上面的屏幕快照中,我使用了Eclipse变量${project_loc},该变量将自动替换为项目"中当前所选项目的基本目录.资源管理器". (这允许对多个项目进行一次运行配置.)
  • 目标,潜在配置文件和几个选项:所有这些选项将弥补将要启动的确切命令.添加配置文件将使用-P...属性启动Maven.选中更新快照"将使用-U标志等启动Maven.
  • a name: this will be the unique name of the configuration. You can name it as you like. Above, it is named with the goals that it will invoke.
  • the base directory: this will be the folder where Maven will be invoked in. In the above screenshot, I used the Eclipse variable ${project_loc}, which is replaced automatically by the base directory of the current selected project in the "Project Explorer" when run. (This allows to have a single run configuration for multiple projects).
  • goals, potential profiles and several options: all those options will make up for the exact command that will be launched. Adding a profile will launch Maven with a -P... attribute; checking "Update Snapshots" will launch Maven with the -U flag, etc.

这很简单:"Maven安装"将在Eclipse中以目标install启动已配置的Maven安装.它将与在外部安装Maven的命令行上运行命令mvn install相同.

This is the simple one: "Maven install" will launch the configured Maven installation in Eclipse with the goal install. It will have the same effect as running the command mvn install on the command-line, with an external Maven installation.

选项"Maven生成源","Maven测试"或"Maven清理"实际上遵循相同的想法:所有这些都将直接通过generate-sources阶段,test阶段或clean阶段.

The options "Maven generate-sources", "Maven test" or "Maven clean" are actually following the same idea: all of those will directly invoke Maven with the generate-sources phase, the test phase or the clean phase.

这实际上将启动上一个对话框,我们在其中创建了新的运行配置.发生的事情是M2Eclipse将创建一个新的,您可以像上面一样完全填充.您可以将其视为创建自定义"Maven Build"运行配置的快捷方式.

This will actually launch the previous dialog where we created a new run configuration. What happens is that M2Eclipse will create a new one, that you can fill exactly like above. You could see it as a short-cut for creating custom "Maven Build" run configurations.

这将尝试启动配置的自定义运行配置.

This will try to launch the configured custom run configurations.

  • 如果只有一个自定义的"Maven Build"运行配置,它将启动该配置.
  • 如果您有多个,它将​​要求您运行一个:

  • If you have only one custom "Maven Build" run configuration, it will launch that one.
  • If you have more than one, it will ask you for the one to run:

在上面的屏幕截图中,您可以看到有两个自定义的"Maven Build"运行配置,分别命名为cleanclean install.因此,此弹出窗口要求用户选择一个.

In the above screenshots, you can see that there was 2 custom "Maven Build" run configuration, which were named clean and clean install. As such, this pop-up is asking the user to select one.

选择了自定义的"Maven构建"配置后,它将使用此运行配置中的选项调用Maven.

Once the custom "Maven Build" configuration was chosen, it will then invoke Maven with the options in this run configuration.

这篇关于"Maven Install"和"Maven Install"之间有什么区别?和"Maven Build"使用M2Eclipse?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆