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
// PomEditor uses sub-object APIs for domain-specific operations
PomEditor editor = new PomEditor();
editor.createMavenDocument("project");
Element root = editor.root();
editor.insertMavenElement(root, MODEL_VERSION, "4.0.0");
editor.insertMavenElement(root, GROUP_ID, "com.example");
editor.insertMavenElement(root, ARTIFACT_ID, "my-project");
editor.insertMavenElement(root, VERSION, "1.0.0");
// Dependencies API
Element deps = editor.insertMavenElement(root, DEPENDENCIES);
editor.dependencies().addDependency(deps, "org.slf4j", "slf4j-api", "2.0.7");
// Plugins API
Element build = editor.insertMavenElement(root, BUILD);
Element plugins = editor.insertMavenElement(build, PLUGINS);
editor.plugins().addPlugin(plugins, "org.apache.maven.plugins", "maven-compiler-plugin", "3.11.0");
// Properties API
Element properties = editor.insertMavenElement(root, PROPERTIES);
editor.properties().addProperty(properties, "maven.compiler.source", "17");
// Subprojects API (for modules)
// editor.subprojects().addModule(modules, "core");
String result = editor.toXml();
Key Features
Maven-Aware Element Ordering
Automatically orders elements according to Maven POM conventions with intelligent blank line insertion.
Sub-Object APIs
Domain-specific APIs for dependencies, plugins, properties, subprojects, and parent management via editor.dependencies(), editor.plugins(), etc.
Convention Detection & Alignment
Auto-detect how your project manages dependency versions and add or transform dependencies to follow those conventions consistently.
Exclusion Management
Full CRUD for dependency exclusions on both regular and managed dependencies.
Profile-Scoped Operations
Scope dependency operations to specific Maven profiles.
Cross-POM Alignment
Move dependency versions from child POMs to parent POM's <dependencyManagement> with automatic property migration.
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
Dependency Management
- Exclusion Management - Add and remove dependency exclusions
- Dependency Alignment - Auto-detect and align conventions
- Profile-Scoped Operations - Manage profile-specific dependencies
- Cross-POM Alignment - Multi-module version management
API Reference
- PomEditor API - Complete method reference
- Coordinates - Maven artifact coordinates
Maven Coordinates
<dependency>
<groupId>eu.maveniverse.maven.domtrip</groupId>
<artifactId>domtrip-maven</artifactId>
<version>1.2.0</version>
</dependency>
Requirements
- Java 8+ - Compatible with a wide range of Java versions
- Maven 3.6+ - Compatible with current Maven versions
- domtrip-core - Automatically included as dependency