Maven Extension
The DomTrip Maven extension provides specialized functionality for working with Maven POM files, extending the core DomTrip library with Maven-specific features and conventions.
Quick Overview
import org.maveniverse.domtrip.maven.PomEditor;
import eu.maveniverse.domtrip.Element;
import static org.maveniverse.domtrip.maven.MavenPomElements.Elements.*;
// Create or edit POM files with Maven-aware ordering
PomEditor editor = new PomEditor();
editor.createMavenDocument("project");
Element root = editor.root();
// Elements are automatically ordered according to Maven conventions
editor.insertMavenElement(root, VERSION, "1.0.0"); // Will be ordered correctly
editor.insertMavenElement(root, MODEL_VERSION, "4.0.0"); // Will come first
editor.insertMavenElement(root, GROUP_ID, "com.example"); // Will be ordered correctly
editor.insertMavenElement(root, ARTIFACT_ID, "my-app"); // Will be ordered correctly
// Add dependencies with convenience methods
Element dependencies = editor.insertMavenElement(root, DEPENDENCIES);
editor.addDependency(dependencies, "org.junit.jupiter", "junit-jupiter", "5.9.2");
String result = editor.toXml(); // Properly formatted with blank lines
Key Features
ποΈ Maven-Aware Element Ordering
Automatically orders elements according to Maven POM conventions with intelligent blank line insertion.
π― Convenience Methods
Specialized methods for common Maven operations like adding dependencies, plugins, modules, and properties.
π§ Type-Safe Constants
Comprehensive constants for Maven elements, attributes, namespaces, and schema locations.
π Formatting Preservation
Maintains original formatting, whitespace, and comments while making changes.
Getting Started
- Installation - Add the Maven extension to your project
- Quick Start - Your first POM editing example in 5 minutes
- API Reference - Complete PomEditor API documentation
Documentation
Core Concepts
- Overview - Understanding the Maven extension architecture
- Element Ordering - How Maven element ordering works
- Examples - Real-world usage examples
API Reference
- PomEditor API - Complete method reference
- MavenPomElements - Constants reference
Use Cases
π οΈ Maven Tooling Development
Perfect for building tools that need to modify POM files:
- Build automation tools
- IDE plugins for Maven
- Dependency management utilities
- POM validation tools
π POM Transformation
Ideal for transforming existing POMs:
- Maven version upgrades
- Dependency updates
- Plugin configuration changes
- Template-based generation
π POM Analysis
Great for analyzing and modifying POMs:
- Security scanning tools
- License compliance checking
- Build optimization
- Dependency analysis
Architecture
βββββββββββββββββββββββββββββββββββββββ
β domtrip-maven β
β β
β βββββββββββββββ ββββββββββββββββββββ
β β PomEditor β β MavenPomElementsββ
β β β β ββ
β β - Maven β β - Element names ββ
β β ordering β β - Attributes ββ
β β - Blank β β - Namespaces ββ
β β lines β β - Schema URIs ββ
β β - Helpers β β - Constants ββ
β βββββββββββββββ ββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββ
β extends
βΌ
βββββββββββββββββββββββββββββββββββββββ
β domtrip-core β
β β
β βββββββββββββββ ββββββββββββββββββββ
β β Editor β β Document ββ
β β β β ββ
β β - Lossless β β - Parsing ββ
β β editing β β - Serialization ββ
β β - Formattingβ β - Navigation ββ
β β preserve β β - Whitespace ββ
β βββββββββββββββ ββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββ
Maven Coordinates
<dependency>
<groupId>eu.maveniverse</groupId>
<artifactId>domtrip-maven</artifactId>
<version>0.2.0</version>
</dependency>
Requirements
- Java 17+ - Built for modern Java
- Maven 3.6+ - Compatible with current Maven versions
- domtrip-core - Automatically included as dependency
Next Steps
Choose your path:
π Get Started Quickly
π Learn the Concepts
π Explore Examples
ποΈ Build Something
Start with the Quick Start Guide and begin editing your first POM file with the Maven extension!