Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you edit Maven pom files?

I have recently started exploring Maven, but I feel a bit overwhelmed of all xml configuration in all the pom files. Are there any good tools i can use?

like image 447
Kristian Avatar asked Nov 26 '08 21:11

Kristian


2 Answers

This tip works with any good XML editor.

By far the best guide you can have is the XML schema (the 'XSD' file), which defines all the structures and what they do.

At the top of your POM, ensure the 'project' element is defined like this:

<project
  xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

Now when you edit the file in any good editor (including jEdit or Eclipse) the editor will actually download the .xsd file from the URL above and use it to guide you and validate the POM.

e.g. in Eclipse, go somewhere in the POM and hit Ctrl-Space - it will bring up a list of valid elements for the current position.

like image 174
Air Avatar answered Sep 21 '22 07:09

Air


m2eclipse, it provides a very nice form-based editor. But I only use the XML view most of the time.

like image 35
Joachim Sauer Avatar answered Sep 23 '22 07:09

Joachim Sauer