Are Maven Clean, Update, Install, and Eclipse Clean, Refresh, Build - usually the correct order?

I have several interconnected Eclipse projects. When I try to create my workspace, I have many problems. Presumably, problems should go if I make Maven clean, update, install and clean up the project, update, create everything (I do everything in Eclipse via the Run and Project menus respectively).

However, I am confused by what should be the best orders to carry out these actions? Also, can someone briefly explain what each of them does so that I can better understand and understand when I can skip some?

In particular: I was told that just running Maven Clean and Maven Install is enough. Although Maven Install ends in "Build Success", I still have errors in the "Problems" tab and the nasty error "Could not find or load export of the main class" when trying to run some classes in a specific project. I try to start Project Clean a couple of times, and then Project Build a couple more times, and errors may or may not go. I was recommended to enter Maven Update β†’ all projects and select all projects> Update (F5) steps, but I'm not sure when to execute them (after cleaning, installing or building).

Is there any β€œcorrect” procedure for performing these actions? So, if I execute it and some errors remain, it becomes clear that something is wrong in my version, and not just with dependencies? I pulled projects from RTC (a collaboration tool for software developers), and my colleagues do not have these problems. However, I just recently pulled it.

+5
source share
2 answers

In particular, in my case, the following sequence of actions worked:

  • Project β†’ Uncheck Build Automatically
  • [accept incoming changes] if applicable
  • Project β†’ Clean
  • Run β†’ Run As β†’ Maven clean
  • Run β†’ Run As β†’ Maven install
  • Project β†’ automatic assembly check
  • If an error message appears on the Problems tab:
    • select all projects, upgrade F5
    • if still errors:
      • Manually remove errors on the Problems tab (Eclipse may not have updated dependencies, etc.).
      • select all projects, upgrade F5
+1
source

First, you must understand that maven and eclipse are two different things. Yes, there is a m2e plugin (which is now part of eclipse) that does a great job of setting up eclipse projects based on maven projects. But sometimes eclipse gets corrupted (almost always due to upgrade issues).

Secondly, you may have to learn about the Maven Build Life Cycle Basics :

There are three built-in build life cycles: default, clean, and site. The default life cycle handles the deployment of your project, the clean life cycle handles the cleanup of the project, and the website life cycle handles the creation of documentation for your project site.

So basically:

  • clean - this is the clean life cycle stage, deletes the target directory
  • install is the default lifecycle stage, it does a lot because the triggers of all the previous stages (generate sources, compile, run tests, etc. and end up putting your packages in your target directory and placing artifacts in the local repository .

Thirdly, about the eclipse. You do not need to run Build if you checked Project β†’ Build Automatically . When eclipse got confused, I found that executing the m2e command β€œ Maven β†’ Update Project ” and then Refresh is enough. This command restores some files in the .settings folder. In some rare cases, I had to delete all the files in the .settings folder, and then run the "Update Project" command.

Conclusion: mvn clean install should do the job, if not eclipse -> Update , if eclipse still does not work -> Maven -> Update project

I also recommend using the latest version of the eclipse and m2e plugin.

+8
source

Source: https://habr.com/ru/post/1241186/