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:
PomEditor- Specialized editor for Maven POM filesMavenPomElements- Constants for Maven POM elements and attributes
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
-
Class Summary Class Description AbstractMavenEditor Abstract base class for Maven-specific editors that provides common element ordering functionality.AlignOptions Options for controlling how dependencies are aligned with project conventions.AlignOptions.Builder Builder forAlignOptions.Coordinates Represents Maven coordinates (groupId, artifactId, version, classifier, and type).ExtensionsEditor Specialized editor for Maven extensions.xml files.MavenExtensionsElements Constants for Maven extensions.xml elements, attributes, and other XML constructs.MavenExtensionsElements.Attributes XML attribute constants used in Maven extensions.MavenExtensionsElements.Elements Common XML element names used in Maven extensions.xml files.MavenExtensionsElements.Files Common file and directory names.MavenExtensionsElements.Namespaces Maven extensions namespace constants.MavenExtensionsElements.SchemaLocations Schema location constants.MavenExtensionsElements.Values Common values and defaults for extensions elements.MavenPomElements Constants for Maven POM elements, attributes, and other XML constructs.MavenPomElements.Attributes XML attribute constants used in Maven POMs.MavenPomElements.Elements Common XML element names used in Maven POMs.MavenPomElements.Files Common file and directory names.MavenPomElements.Indentation Common indentation patterns for XML formatting.MavenPomElements.ModelVersions Maven model version constants.MavenPomElements.Namespaces Maven namespace constants.MavenPomElements.Plugins Common Maven plugin constants.MavenPomElements.SchemaLocations Schema location constants.MavenSettingsElements Constants for Maven settings.xml elements, attributes, and other XML constructs.MavenSettingsElements.Attributes XML attribute constants used in Maven settings.MavenSettingsElements.Elements Common XML element names used in Maven settings.xml files.MavenSettingsElements.Files Common file and directory names.MavenSettingsElements.Namespaces Maven settings namespace constants.MavenSettingsElements.SchemaLocations Schema location constants.MavenSettingsElements.Values Common values and defaults for settings elements.MavenToolchainsElements Constants for Maven toolchains.xml elements, attributes, and other XML constructs.MavenToolchainsElements.Attributes XML attribute constants used in Maven toolchains.MavenToolchainsElements.Elements Common XML element names used in Maven toolchains.xml files.MavenToolchainsElements.Files Common file and directory names.MavenToolchainsElements.Namespaces Maven toolchains namespace constants.MavenToolchainsElements.SchemaLocations Schema location constants.MavenToolchainsElements.ToolchainTypes Common toolchain types.MavenToolchainsElements.Values Common values for toolchain elements.PomEditor Specialized editor for Maven POM files that extends the baseEditorclass with Maven-specific functionality and element ordering.SettingsEditor Specialized editor for Maven settings.xml files.ToolchainsEditor Specialized editor for Maven toolchains.xml files. -
Enum Summary Enum Description AlignOptions.PropertyNamingConvention Naming convention for version properties.AlignOptions.VersionSource Whether the version value is a literal or a property reference.AlignOptions.VersionStyle Whether the dependency version is inline or delegated to dependency management.