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

  1. Installation - Add the Maven extension to your project
  2. Quick Start - Your first POM editing example in 5 minutes
  3. API Reference - Complete PomEditor API documentation

Documentation

Core Concepts

API 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!