Package eu.maveniverse.domtrip.maven


package eu.maveniverse.domtrip.maven
Maven-specific extensions for the DomTrip XML editing library.

This package provides specialized classes for working with Maven POM files, extending the core DomTrip functionality with Maven-specific features:

Key Features

  • Maven Element Ordering - Automatically orders elements according to Maven conventions
  • Formatting Preservation - Maintains original formatting, whitespace, and comments
  • Intelligent Blank Lines - Adds appropriate blank lines between element groups
  • Maven-specific Methods - Convenience methods for common POM operations

Usage Example

// Parse existing POM
Document doc = Document.of(pomXmlString);
PomEditor editor = new PomEditor(doc);

// Add elements with proper ordering
Element root = editor.root();
editor.insertMavenElement(root, "description", "My project description");
editor.insertMavenElement(root, "name", "My Project");  // Will be ordered before description

// Add dependencies
Element dependencies = editor.findChildElement(root, "dependencies");
if (dependencies == null) {
    dependencies = editor.insertMavenElement(root, "dependencies");
}
editor.addDependency(dependencies, "org.junit.jupiter", "junit-jupiter", "5.9.2");

// Serialize with preserved formatting
String result = editor.toXml();
Since:
0.1