Building Maven projects

Once our Maven project has been integrated in the Eclipse IDE, all the phases of the build lifecycle, up to the compile phase, are executed automatically in the background by the IDE itself. So, we can see that under the /target folder, there are the compiled .class files corresponding to our project sources and test sources as well as the filtered project and test resources. If we want to build our project till the needed phase, we have to invoke Maven explicitly: this can be done following the Run As (or Debug As) menu and then selecting the desired phase, as shown in the following screenshot:

Building Maven projects

Maven build options in the Run As menu

If we want to launch Maven with a phase or a goal that is not listed in the pop-up menu, we can click on the Maven Build… menu item and fill the dialog window shown in the following screenshot:

Building Maven projects

Edit the Maven build configuration

Here, other parameters can also be specified, for example, the Skip Tests checkbox (corresponding to the -Dmaven.test.skip=true parameter on the command line) if we want to skip the compilation and execution of the unit tests, or the Debug Output checkbox (corresponding to the –X parameter) to enable debug output, or the Non-recursive checkbox (corresponding to the –N parameter) that avoids building child modules.

In all these cases, the Maven output is displayed in the Console view of the Eclipse IDE. From the Console view, we can click on the Open Console icon on the right-hand side of the toolbar and then on the Maven Console menu item. We will see the Maven commands that are launched by the m2e plugin, and the logs of all the activities executed in the background.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset