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:
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?
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.
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:
By going to:
This will open a dialog where you can configure those custom configurations.
You can create a new "Maven Build" run configuration, by giving it:
${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).-P...
attribute; checking "Update Snapshots" will launch Maven with the -U
flag, etc.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.
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.
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.
If you have more than one, it will ask you for the one to run:
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.
Once the custom "Maven Build" configuration was chosen, it will then invoke Maven with the options in this run configuration.