What exactly does Maven Update Project do in Eclipse?

…衆ロ難τιáo~ 提交于 2019-11-28 10:58:25
GauravJ

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

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

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.

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.

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

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".

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. 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

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

Update Project configuration is majorly related to

  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.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!