Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring Maven 2 POM Editor to open pom.xml files in source mode

I use the Maven 2 POM Editor mainly for editing POM XML files directly. Is there a way to make the editor always open files in the "Source" tab?

like image 668
tputkonen Avatar asked Jan 18 '10 08:01

tputkonen


People also ask

How can I open POM xml file?

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".

What is Modelversion in POM xml?

model version is the version of project descriptor your POM conforms to. It needs to be included and is set. The value 4.0. 0 just indicated that it is compatible Maven 3.

How do I use Maven in POM xml?

xml. The POM contains information about the project and various configuration detail used by Maven to build the project(s). Before creating a POM, we should first decide the project group (groupId), its name (artifactId) and its version as these attributes help in uniquely identifying the project in repository.


2 Answers

In the Eclipse preferences for the Maven plugin, there is a check box for Open XML page in the POM editor by default. Its exact location varies by plugin version.

Juno/Kepler/Luna/Mars (4.x)

In these versions of Eclipse:

  1. Click Window → Preferences
  2. Expand Maven
  3. Click User Interface
  4. Check Open XML page in the POM editor by default
  5. Click Apply and Close

POMs will open in source view by default.

Helios/Indigo (3.x)

In these versions of Eclipse:

Maven > POM Editor

like image 59
Jherico Avatar answered Oct 20 '22 01:10

Jherico


Like Damien suspected, myWindow>Preferences>Maven>User Interface option to open POMs in the Maven POM editor automatically was indeed broken. Here's how I fixed it (Juno):

Open Window>Preferences>General>Editors>File Associations. In the upper right area click Add..., type "pom.xml", then OK.

Then click on the new entry pom.xml in the upper list, and in the lower list click on Maven POM Editor, then click the Default button on the right.

Click OK and then double click your pom.xml file in project explorer and it should open in the Maven POM editor.

Bonus: The Ctrl+Shift+F formatting does a sweet job of formatting POMs in the Maven editor. The default XML editor's formatting is pretty bad for POMs, which have attribute-free tags.

like image 33
William T. Mallard Avatar answered Oct 20 '22 03:10

William T. Mallard