Building and packaging Maven projects needs execution of required phases, which we discussed in the preceding sections. Let's build and package hello-project from Chapter 3, Creating and Importing Projects, which we generated using archetypes. In the Default Lifecycle section, the phase package executes the following phases in order: compile, test, and package phases. Now, we will see how to invoke the package phase from m2eclipse. The following steps will ascertain this:
Right-click on hello-project and select Run As. Click on Run Configurations and the Run Configurations window will appear.
Right-click on Maven Build and choose New as shown in the following screenshot:
Once the launch configurations window appears, fill in the details as shown in the following screenshot. For Base Directory, click on Browse Workspace... and choose hello-project from the pop-up list:
Next, click on Apply and close it using the Close button.
Again right-click on the project and select Run As, and click on Maven build as shown in the following screenshot:
A window, as shown in the following screenshot, will appear with all the run configurations available:
Choose the hello-package launch configuration and click on OK. It should compile, run tests, generate site documentation, and package in the target directory, as shown in following screenshot: