117

What does "Maven -> Update Project..." do in Eclipse?

enter image description here

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Ashish
  • 14,295
  • 21
  • 82
  • 127
  • 5
    It just makes a refresh to reload the maven configuration file again. – shakthydoss Dec 12 '13 at 15:07
  • Please check this answer, http://stackoverflow.com/questions/42554213/what-exactly-does-maven-update-project-do-in-eclipse?answertab=votes#tab-top – GauravJ Mar 03 '17 at 11:25

3 Answers3

99

It syncs the Eclipse project settings with that of the pom. If you for example change important plugin settings, such as the output java version, you will find that Eclipse will ask you to update the project and afterwards the configured Java runtime in the project will have changed to reflect what your Maven pom indicates.

That is an important thing to keep in mind: the Maven pom is the lead in this kind of project setup. If you want settings to change, try to do that through the pom and not through Eclipse project settings directly or doing a project update might revert what you have changed. There are usually some things I have to correct myself anyway though, such as build path exclusions that m2eclipse likes to put in and strange deployment assembly configurations.

Gimby
  • 5,095
  • 2
  • 35
  • 47
  • 23
    I was hoping to hear specifically what maven commands and plugins were executed as well. – Gray Mar 24 '14 at 17:47
  • @Gimby Right now I have an strange situation about it. I'm working in JPA project with DataNucleus. When I try compile (mvn package) from console it doesn't detect WEB-INF/persistence.xml until I use 'Update Project...' option in eclipse. After that 'mvn package' command works perfect!! If I use 'mvn clean' and try 'mvn package' problem appears again. Why doing this could resolving the problem? I was expected only maven console commands or modifications from console could have some effect in Eclipse proyect, but not in reverse situation. – molavec Jul 10 '14 at 00:28
  • 1
    if i never update maven configuration in Eclipse, is there ever any need to run Maven Update ? – amphibient Aug 15 '16 at 21:48
  • 1
    @amphibient no not really. Even if Eclipse messes up and gets confused about the workspace state (it happens), a simple project clean always resolves it. – Gimby Aug 16 '16 at 07:26
  • @Gimby Thank you for sharing. How do you know this? Is there any official statement (available online) about the 'Update Project' command or the 'Update Maven Project' dialog? Can you please provide the link? (FYI The only documented occurrence I have found was in m2e documentation, and it is utterly insufficient (see https://www.eclipse.org/m2e/documentation/release-notes-15.html) – KiriSakow Nov 29 '17 at 11:24
  • 1
    @KiriSakow personal experience and observation. It's rather simple; change project settings in Eclipse, do update project, see your changes being reverted. Do keep in mind that this answer is ageing, it does not necessarily represent modern versions of m2eclipse. – Gimby Nov 29 '17 at 11:50
  • 1
    Hello @Gimby. Where can I find the perfectly availabile information about Maven update? – Witold Kaczurba Jun 01 '18 at 07:53
  • @WitoldKaczurba Who knows, maybe only on the internet 4 years ago when that comment was made. I suggest google. – Gimby Jun 01 '18 at 08:02
  • if i do not do mvn update and just do mvn build in eclipse - i get errors. so i have to do mvn update each time i need a build. – mrtechmaker Oct 04 '18 at 10:09
  • @KaranAhuja the only thing I can say about that is: that absolutely isn't normal, something is very wrong in your workspace. – Gimby Oct 04 '18 at 10:41
  • @Gimby - Thanks for reply. I am using eclipse photon. Should I use oxygen instead of photon ? – mrtechmaker Oct 05 '18 at 06:19
  • Is a `mvn eclipse:eclipse` run by `Maven -> Update Project` or is Eclipse updating the project by its own means? – Alexis Dufrenoy Oct 29 '18 at 10:02
  • People, if you have questions then hit the "ask question" button. Don't keep asking questions in comments on an answer that was posted 4-5 Eclipse releases ago. – Gimby Oct 29 '18 at 10:19
  • It's a little clarification on the subject of the question, which could possibly interest lots of the persons arriving here... – Alexis Dufrenoy Oct 29 '18 at 10:32
  • Does anyone know the equivalent of the Maven "Update Project" button for IntelliJ IDEA? – that_developer Feb 17 '22 at 19:15
  • 1
    @that_developer right click the project -> maven -> reload project. It is not a true equivalent though. The project names are stored in the generated .idea file, if you want to refresh those you'll have to remove that file and reopen the project from the pom file. – Gimby Feb 18 '22 at 09:03
  • thanks @Gimby I will look into this!!! – that_developer Feb 20 '22 at 00:14
22

To add on to what @Gimby said - Update Project also provides more options such as Force Update of Snapshots / Releases which is extremely helpful when you have dependencies that are looking for the latest. (e.g.: [1.0) will find 1.0.* - whatever's the latest.)

Updating project is synonymous with Ivy's Resolve. It will make sure that all referenced dependencies are there, as well as clean the project to make sure that they are included correctly.

ddavison
  • 28,221
  • 15
  • 85
  • 110
  • 1
    Dependencies go well without any project update though; just update the pom and the dependencies auto-update in the Eclipse project. Good thing too, otherwise it would be quite a chore to work with Maven in Eclipse! – Gimby Dec 12 '13 at 15:39
  • I agree, maven update project will update the eclipse according to pom.xml configuration ( eg java version). – Sanchi Girotra Aug 06 '18 at 06:15
2

I could not dig out the documentaiton, but I was able to dig out the code. To complement @Gimby answer - you can go into details and look into what the function does in here:

https://github.com/eclipse/m2e-core/blob/41f5ae34ad2543ef1439b7fd7e0a03b596af8685/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ProjectConfigurationManager.java#L365

Look for : updateProjectConfiguration0 function.

Cheers,

Witold Kaczurba
  • 9,845
  • 3
  • 58
  • 67
  • 1
    It seems to have [moved](https://github.com/eclipse-m2e/m2e-core/blob/23eeb317c1b92aa725089a988f5d229a5cbfdc36/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/project/ProjectConfigurationManager.java#L373>). – Per Mildner Feb 09 '22 at 11:27