Maven Extension Overview

The DomTrip Maven extension (domtrip-maven) provides specialized functionality for working with Maven configuration files, extending the core DomTrip library with Maven-specific features and conventions.

Key Features

πŸ—οΈ Maven-Aware Element Ordering

The PomEditor automatically orders elements according to Maven POM conventions:

  • Project elements: modelVersion, parent, groupId, artifactId, version, packaging, name, description, etc.
  • Build elements: defaultGoal, directory, finalName, sourceDirectory, etc.
  • Plugin elements: groupId, artifactId, version, extensions, executions, etc.
  • Dependency elements: groupId, artifactId, version, classifier, type, scope, etc.

πŸ“ Intelligent Blank Line Management

Automatically adds appropriate blank lines between element groups to maintain readable POM structure:

<project>
  <modelVersion>4.0.0</modelVersion>
  
  <parent>
    <groupId>org.example</groupId>
    <artifactId>parent</artifactId>
    <version>1.0.0</version>
  </parent>
  
  <groupId>com.example</groupId>
  <artifactId>my-project</artifactId>
  <version>1.0.0</version>
  <packaging>jar</packaging>
  
  <name>My Project</name>
  <description>An example project</description>
</project>

🎯 Convenience Methods

Specialized methods for common Maven operations:

  • PomEditor: addDependency(), addPlugin(), addModule(), addProperty()
  • SettingsEditor: addServer(), addMirror(), addProxy(), addProfile()
  • ExtensionsEditor: addExtension() with proper coordinates
  • ToolchainsEditor: addJdkToolchain(), addNetBeansToolchain(), addToolchain()

πŸ”§ Type-Safe Constants

Comprehensive constants classes for all Maven file types:

  • MavenPomElements: POM elements, attributes, namespaces, and schema locations
  • MavenSettingsElements: Settings elements, values, and configuration options
  • MavenExtensionsElements: Extensions elements and common extension types
  • MavenToolchainsElements: Toolchain elements, types, and common vendors

Architecture

The Maven extension is built on top of the core DomTrip library:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      domtrip-maven                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚ PomEditor   β”‚ β”‚SettingsEditorβ”‚ β”‚ExtensionsEd.β”‚ β”‚Toolchainβ”‚β”‚
β”‚  β”‚             β”‚ β”‚             β”‚ β”‚             β”‚ β”‚Editor   β”‚β”‚
β”‚  β”‚ - POM       β”‚ β”‚ - Settings  β”‚ β”‚ - Extensionsβ”‚ β”‚ - Tool  β”‚β”‚
β”‚  β”‚   ordering  β”‚ β”‚   ordering  β”‚ β”‚   ordering  β”‚ β”‚   chainsβ”‚β”‚
β”‚  β”‚ - Deps/     β”‚ β”‚ - Servers/  β”‚ β”‚ - Extension β”‚ β”‚ - JDK   β”‚β”‚
β”‚  β”‚   Plugins   β”‚ β”‚   Mirrors   β”‚ β”‚   coords    β”‚ β”‚   setup β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚                   Constants Classes                     β”‚β”‚
β”‚  β”‚ MavenPomElements | MavenSettingsElements |              β”‚β”‚
β”‚  β”‚ MavenExtensionsElements | MavenToolchainsElements       β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        domtrip-core                         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚ Editor      β”‚ β”‚ Document        β”‚ β”‚ Configuration       β”‚β”‚
β”‚  β”‚             β”‚ β”‚                 β”‚ β”‚                     β”‚β”‚
β”‚  β”‚ - Lossless  β”‚ β”‚ - Parsing       β”‚ β”‚ - Formatting        β”‚β”‚
β”‚  β”‚   editing   β”‚ β”‚ - Serialization β”‚ β”‚ - Whitespace        β”‚β”‚
β”‚  β”‚ - Formattingβ”‚ β”‚ - Navigation    β”‚ β”‚ - Indentation       β”‚β”‚
β”‚  β”‚   preserve  β”‚ β”‚ - Validation    β”‚ β”‚                     β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Use Cases

The Maven extension is perfect for:

πŸ› οΈ Maven Tooling Development

  • Build tools that need to modify POM files
  • IDE plugins for Maven project management
  • Automated dependency management tools
  • POM validation and cleanup utilities

πŸ”„ POM Transformation

  • Upgrading Maven versions while preserving formatting
  • Migrating between different Maven configurations
  • Batch updates across multiple projects
  • Template-based POM generation

πŸ“Š POM Analysis

  • Dependency analysis tools
  • Security scanning with POM modification
  • License compliance checking
  • Build optimization tools

Comparison with Standard XML Libraries

Feature Standard XML DomTrip Core DomTrip Maven
Formatting Preservation ❌ βœ… βœ…
Comment Preservation ❌ βœ… βœ…
Whitespace Preservation ❌ βœ… βœ…
Maven Element Ordering ❌ ❌ βœ…
Maven Conventions ❌ ❌ βœ…
POM-specific Methods ❌ ❌ βœ…
Maven Constants ❌ ❌ βœ…

Getting Started

Ready to start using the Maven extension? Check out:

Next Steps