Developing with Eclipse and Maven

8.2. Using the Form-based POM Editor

8.2. Using the Form-based POM Editor

The latest release of the m2eclipse plugin has a form-based POM editor which allows you to edit every part of a project's pom.xml with an easy-to-use GUI interface. To open the POM Editor, click on a project's pom.xml file. If you've customized the editors for a pom.xml file, and the POM Editor is not the default editor, you may need to right-click on the file and choose "Open With... / Maven POM Editor". The POM Editor will then display the Overview tab as shown in Figure 8.2, “Overview Tab of POM Editor for idiom-core”.

Note

The Form-based POM Editor is only available if you selected the POM Editor component when you installed the m2eclipse Eclipse plugin. For more information about installing the m2eclipse plugin, see Section 2.3.1, “Installing m2eclipse Core Components”.

One common complaint about Maven is that it forces a developer to confront large and often overwhelming XML documents in a highly complex multi-module project build. While the authors of this book believe this is a small price to pay for the flexibility of a tool like Maven, the graphical POM editor is a tool that makes it possible for people to use Maven without ever having to know about the XML structure behind a Maven POM.

Overview Tab of POM Editor for idiom-core

Figure 8.2. Overview Tab of POM Editor for idiom-core


The project shown in Figure 8.2, “Overview Tab of POM Editor for idiom-core” is a project with an artifactId of of idiom-core. You'll notice that most of the fields in this idiom-core project are blank. There is no groupId or version and there is no SCM information supplied in the POM editor. This is due to the fact that idiom-core inherits most of this information from a parent project named idiom. If we open the pom.xml for the parent project in the POM Editor we would see the Overview tab shown in Figure 8.3, “Overview Tab of POM Editor for idiom Parent Project”.

That “open folder” icon on the various list entries throughout the POM editor indicate that the corresponding entry is present in the Eclipse workspace and “jar” icon indicates artifacts which are referenced from the Maven repository. You can double-click on those entries in order to open its POM in the POM editor. This works for modules, dependencies, plugins and other elements that have corresponding Maven artifacts. Underlined labels in several POM editor sections represent hyperlinks which can be used to open the POM editor for corresponding Maven artifact.

Overview Tab of POM Editor for idiom Parent Project

Figure 8.3. Overview Tab of POM Editor for idiom Parent Project


In this parent POM, we see that the groupId and version are defined and that the parent POM supplies much of the information which was missing in the idiom-core project. The POM editor is going to show you the contents of the POM that you are editing, and it will not show you any of the inherited values. If you wanted to look at the idiom-core project's effective POM in the POM editor, you can use “Show Effective POM” action from the tool-bar in the upper right-hand corner of the POM editor, which shows a left bracket and an equals sign on a page with a blue M. It will load the effective POM for idiom-code in the POM Editor as shown in Figure 8.4, “Effective POM for idiom-core”.

Effective POM for idiom-core

Figure 8.4. Effective POM for idiom-core


This effective view of the POM merges the idiom-core POM with the ancestor POMs (the parent, the grandparent, etc.), similarly to “mvn help:effective-pom” command and displays the POM editor with the effective values. Because the POM editor is display a composite view of many different merged POMs, this effective POM Editor is read-only, and you will not be able to update any of the fields in this effective POM view.

If you were looking at the POM editor for the idiom-core project as shown in Figure 8.2, “Overview Tab of POM Editor for idiom-core”, you can also navigate to the parent POM using, ”Open Parent POM” action from the POM editor tool-bar in the upper right-hand of the POM editor.

The POM editor shows a number of showing various information from the POM. The final tab exposes the pom.xml as an XML document. There is a dependencies tab shown in Figure 8.5, “Dependencies Tab of the POM Editor” which exposes an easy-to-use interface for adding and editing dependencies to your project, as well as editing the dependencyManagement section of the POM. This dependency management screen is also integrated with the artifact searching facilities in the m2eclipse plugin. You can use actions from the editor sections, as well as Ctrl-Space typing assistance for the fields in “Dependency Details” section.

If you need to know more about one of the artifacts, you can use “Open Web Page” action from “Dependency Details” section tool-bar to check the project web page.

Dependencies Tab of the POM Editor

Figure 8.5. Dependencies Tab of the POM Editor


The build tab shown in Figure 8.6, “Build Tab of the POM Editor” provides access to the contents of the build element. From this tab you can customize source directories, add extensions, change the default goal name, and add resources directories.

Build Tab of the POM Editor

Figure 8.6. Build Tab of the POM Editor


We only showed a small subset of the POM editor. If you are interested in seeing the rest of the tabs, please download and install the m2eclipse plugin.