or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

build-config.mdcore-model.mddependencies.mdindex.mdmodel-merging.mdprofiles.mdproject-metadata.mdrepositories.mdutility-classes.mdxml-io.md
tile.json

tessl/maven-org-apache-maven--maven-model

Model for Maven POM (Project Object Model)

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.apache.maven/maven-model@3.9.x

To install, run

npx @tessl/cli install tessl/maven-org-apache-maven--maven-model@3.9.0

index.mddocs/

Maven Model

A comprehensive Java library providing the core object model for Maven POM (Project Object Model) files. Maven Model defines the structure and data types used to represent Maven projects, enabling parsing, validation, and manipulation of project definitions consistently across the entire Maven build system.

Package Information

  • Package Name: org.apache.maven:maven-model
  • Package Type: maven
  • Language: Java
  • Installation: Add dependency to pom.xml:
<dependency>
    <groupId>org.apache.maven</groupId>
    <artifactId>maven-model</artifactId>
    <version>3.9.11</version>
</dependency>

Core Imports

import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.apache.maven.model.merge.ModelMerger;

Basic Usage

import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import java.io.FileReader;
import java.io.FileWriter;

// Reading a POM file
MavenXpp3Reader reader = new MavenXpp3Reader();
Model model = reader.read(new FileReader("pom.xml"));

// Accessing model data
String groupId = model.getGroupId();
String artifactId = model.getArtifactId();
String version = model.getVersion();
List<Dependency> dependencies = model.getDependencies();

// Writing a POM file
MavenXpp3Writer writer = new MavenXpp3Writer();
writer.write(new FileWriter("output.xml"), model);

// Creating a new model programmatically
Model newModel = new Model();
newModel.setModelVersion("4.0.0");
newModel.setGroupId("com.example");
newModel.setArtifactId("my-project");
newModel.setVersion("1.0.0");

Architecture

The Maven Model is built around a hierarchical object structure that mirrors the XML structure of Maven POM files:

  • Model: Root container representing the entire project definition
  • ModelBase: Shared foundation for Model and Profile containing common build elements
  • Generated Classes: 40+ POJOs generated from Modello MDO definitions representing all POM elements
  • I/O Layer: XML readers and writers for serialization with location tracking support
  • Merging System: Sophisticated inheritance and profile merging through ModelMerger

This design enables Maven to consistently parse, validate, manipulate, and generate POM files across all Maven tools and plugins while maintaining full fidelity to the original XML structure and supporting advanced features like inheritance, profiles, and error location tracking.

Capabilities

Core Model Classes

The main Model class and fundamental structure classes that represent the root POM elements and shared build configuration.

public class Model extends ModelBase {
    public String getModelVersion();
    public void setModelVersion(String modelVersion);
    public Parent getParent();
    public void setParent(Parent parent);
    public String getGroupId();
    public void setGroupId(String groupId);
    public String getArtifactId();
    public void setArtifactId(String artifactId);
    public String getVersion();
    public void setVersion(String version);
    public String getPackaging();
    public void setPackaging(String packaging);
    public String getName();
    public void setName(String name);
    public String getDescription();
    public void setDescription(String description);
}

Core Model Classes

Dependency Management

Classes for managing project dependencies, dependency scopes, exclusions, and dependency management sections.

public class Dependency {
    public String getGroupId();
    public String getArtifactId(); 
    public String getVersion();
    public String getScope();
    public String getType();
    public String getClassifier();
    public List<Exclusion> getExclusions();
    public boolean isOptional();
    public String getSystemPath();
}

Dependency Management

Build Configuration

Build-related classes including Build, BuildBase, plugins, executions, and resource management.

public class Build extends BuildBase {
    public String getSourceDirectory();
    public String getScriptSourceDirectory();
    public String getTestSourceDirectory();
    public String getOutputDirectory();
    public String getTestOutputDirectory();
    public String getDirectory();
    public String getFinalName();
    public List<String> getFilters();
    public PluginManagement getPluginManagement();
}

Build Configuration

Repository Management

Repository and deployment configuration including repository policies, authentication, and distribution management.

public class Repository extends RepositoryBase {
    public RepositoryPolicy getReleases();
    public RepositoryPolicy getSnapshots();
    public void setReleases(RepositoryPolicy releases);
    public void setSnapshots(RepositoryPolicy snapshots);
}

Repository Management

Profile System

Profile definitions, activation conditions, and profile-specific build configuration.

public class Profile extends ModelBase {
    public String getId();
    public void setId(String id);
    public Activation getActivation();
    public void setActivation(Activation activation);
    public Build getBuild();
    public void setBuild(Build build);
}

Profile System

Project Metadata

Comprehensive classes for project metadata including organization, developers, licenses, mailing lists, SCM, and management systems.

public class Developer extends Contributor {
    public String getId();
    public void setId(String id);
    public List<String> getRoles();
    public void setRoles(List<String> roles);
}

public class Scm {
    public String getConnection();
    public String getDeveloperConnection();
    public String getUrl();
    public String getTag();
    public boolean isChildScmUrlInheritAppendPath();
    public void setChildScmUrlInheritAppendPath(boolean value);
}

Project Metadata

XML I/O Operations

XML readers and writers for serializing models to and from POM files with location tracking and formatting preservation.

public class MavenXpp3Reader {
    public Model read(Reader reader) throws IOException, XmlPullParserException;
    public Model read(InputStream in) throws IOException, XmlPullParserException;
    public Model read(Reader reader, boolean strict) throws IOException, XmlPullParserException;
    public Model read(InputStream in, boolean strict) throws IOException, XmlPullParserException;
}

XML I/O Operations

Model Merging

Model inheritance and merging capabilities for parent-child POM relationships and profile integration.

public class ModelMerger {
    public void merge(Model target, Model source, boolean sourceDominant, Map<?, ?> hints);
    public void mergeModel(Model target, Model source, boolean sourceDominant, Map<?, ?> hints);
    public void mergeModelBase(ModelBase target, ModelBase source, boolean sourceDominant, Map<?, ?> hints);
}

Model Merging

Utility Classes

Supporting classes including build extensions, file sets with pattern matching, and location tracking interfaces.

public class Extension {
    public String getGroupId();
    public String getArtifactId();
    public String getVersion();
}

public class FileSet extends PatternSet {
    public String getDirectory();
    public List<String> getIncludes();
    public List<String> getExcludes();
}

public interface InputLocationTracker {
    InputLocation getLocation(Object key);
    void setLocation(Object key, InputLocation location);
}

Utility Classes

Types

Location Tracking

public class InputLocation {
    public int getLineNumber();
    public int getColumnNumber();
    public InputSource getSource();
    public Map<Object, InputLocation> getLocations();
}

public class InputSource {
    public String getLocation();
    public String getModelId();
}