Maven更新项目在Eclipse中做了什么? [英] What exactly does Maven Update Project do in Eclipse?

查看:127
本文介绍了Maven更新项目在Eclipse中做了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我知道这个问题,但我对这里没有提供的细节感兴趣。

First of all, I am aware of this question, but I am interested in the details which are not provided there.

我看了一下 m2eclipse ,发现它不能令人满意。我可以找到的唯一相关部分是

I had a look at the documentation of m2eclipse and found it unsatisfactorily laconic. The only relevant part I could find is


或者,您可以从项目弹出菜单运行Maven / Update项目配置操作,配置为默认运行进程资源,也可以在同一首选项页面上进行更改。

Alternatively you can run "Maven / Update project configuration" action from the project popup menu, which is configured to run "process-resources" by default and it can be also changed on the same preference page.

但是我无法更新项目配置更新项目相同。我浏览时发现的所有其他资料都不提供任何细节。

but I could not make whether Update project configuration is the same as Update project. All other sources I have found while browsing around do not provide any details either.

要概述,我想知道的是:

To recap, what I would like to know is:


  1. 更新项目运行任何Maven插件,如果是,哪些和哪些默认设置? >
  2. 是否有不是Maven插件的结果,而是Eclipse内部的影响?

  3. 项目结构有哪些修改?例如,在本地复制的Maven依赖关系?

  1. Does Update project run any Maven plugin and, if so, which ones and with which default settings?
  2. Are there effects which are not a result of a Maven plugin, but are internal to Eclipse?
  3. What are the modifications on the project structure? For instance, are Maven dependencies copied locally?


推荐答案


更新项目运行任何Maven插件,如果是,哪些和哪些默认设置?

Does Update project run any Maven plugin and, if so, which ones and with which default settings?

在更新项目期间,m2eclipse使用maven -core构建项目对象模型。具体来说, maven模型构建器用于构建项目模型。换句话说,它导致依赖关系解决,错误和警告通知。有关结果的更多信息,您可以查看 org.apache.maven.project.ProjectBuildingResult

During the update project, m2eclipse uses maven-core build project object model. Specifically, maven model builder is used to build project model. In other words, it leads to dependency resolution, error and warning notification. For more information about the result, you can check org.apache.maven.project.ProjectBuildingResult

认为它会导致插件的运行。在进行更新时,我粗略地看了一下第2阶段没有启用插件处理。

I don't think that it results in running of plugins. I took a cursory look and phase 2 while doing update is not enabled which does plugin processing.


是否有不是Maven插件的结果,而是内部的影响? / p>

Are there effects which are not a result of a Maven plugin, but are internal to Eclipse?

是的。请参阅答案的最后一节。

Yes. See the end section of the answer.


项目结构有哪些修改?例如,在本地复制的Maven依赖关系?

What are the modifications on the project structure? For instance, are Maven dependencies copied locally?

如果在本地你的意思是,在eclipse工作区然后没有。 Maven依赖关系显示对本地存储库的引用,通常是/.m2/repository。还可以根据Eclipse菜单Windows->首选项 - >用户设置的设置解析存储库。

If by locally you mean, in eclipse workspace then no. Maven Dependencies shows reference to the local repository which is usually /.m2/repository. The Repository is also resolved based on the setting of Eclipse menu "Windows->Preference->User Settings".

有关更多信息,您可以从以下源代码(执行时调用的方法之一)在eclipse中更新项目),

For further information, you can begin from the following source code (one of the methods invoked when you do update project in eclipse),

public IStatus runInWorkspace(IProgressMonitor monitor) {
     ...... Unimportant stuff  

    MavenUpdateRequest request = new MavenUpdateRequest(projects, offline,forceUpdateDependencies);
    Map<String, IStatus> updateStatus = configurationManager.updateProjectConfiguration(request, updateConfiguration,
    cleanProjects, refreshFromLocal, monitor);


...... Unimportant stuff  

}

执行不同任务的摘要(不详尽)

Summary of different tasks performed (not exhaustive)


  1. 项目已刷新尊重文件系统。这类似于在eclipse中的java项目上调用刷新。

  2. 检查工作区中是否添加了一个依赖关系。您必须注意在maven依赖项下的本地项目文件夹。 Junit和其他东西将使用此功能选择更改。

  3. 使用maven-core库构建maven项目模型。

  4. 生命周期映射刷新 - M2Eclipse尝试将一些插件生命周期映射到eclipse操作。有关详细信息,请检查

  5. 最后,使用Eclipse构建机制构建项目

  1. Project is refreshed with respect to file system. This is similar to calling refresh on the java project in eclipse.
  2. Check if one of the dependencies have been added in the workspace. You must have noticed under maven dependencies local project folder. Junit and other stuff will pick changes using this feature.
  3. Build maven project model using maven-core libraries.
  4. Lifecycle mapping refresh - M2Eclipse tries to map some of the plugin lifecycles to eclipse actions. For more information, check
  5. Finally, Builds Project using Eclipse build mechanism

此外,它在这种情况下,工作空间中也有一些父母pom存在的东西,这不是很重要。

Additionally, it also does some stuff with parent pom presence in the workspace which is not very important in this context.

更新项目配置主要与


  1. 添加Maven属性(.project文件中的org.eclipse.m2e.core.maven2Nature) - 在您的上下文中不重要。请参阅

  2. 根据 project.build.sourceEncoding maven属性设置项目的默认字符集。


  1. Adding Maven nature (org.eclipse.m2e.core.maven2Nature in .project file) - not important in your context. See this.
  2. Setting default charset for your project based on project.build.sourceEncoding maven property.
  3. Eclipse - plugin lifecycle processing. Point 3 above.

这篇关于Maven更新项目在Eclipse中做了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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