CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-apache-maven--maven-compat

Maven2 compatibility layer providing legacy APIs for Maven3 environment.

Pending
Overview
Eval results
Files

metadata-processing.mddocs/

Metadata Processing

Dependency metadata processing, graph management, and classpath transformation for Maven2 compatibility patterns.

Capabilities

MetadataSource

Interface for retrieving metadata from repositories.

/**
 * Interface for retrieving metadata from repositories
 */
public interface MetadataSource {
    /**
     * Role constant for Plexus component lookup
     */
    String ROLE = MetadataSource.class.getName();
    
    /**
     * Retrieves metadata for an artifact from repositories
     * @param artifact artifact metadata to retrieve
     * @param localRepository local repository
     * @param remoteRepositories list of remote repositories to search
     * @return MetadataResolution containing retrieved metadata
     * @throws MetadataRetrievalException if retrieval fails
     */
    MetadataResolution retrieve(ArtifactMetadata artifact, ArtifactRepository localRepository,
                              List<ArtifactRepository> remoteRepositories) 
                              throws MetadataRetrievalException;
}

DefaultMetadataSource

Default implementation of MetadataSource.

/**
 * Default implementation of MetadataSource
 */
public class DefaultMetadataSource implements MetadataSource {
    /**
     * Retrieves metadata for an artifact from repositories
     */
    public MetadataResolution retrieve(ArtifactMetadata artifact, ArtifactRepository localRepository,
                                     List<ArtifactRepository> remoteRepositories) 
                                     throws MetadataRetrievalException;
}

ClasspathTransformation

Interface for transforming metadata graphs into classpath containers.

/**
 * Interface for transforming metadata graphs into classpath containers
 */
public interface ClasspathTransformation {
    /**
     * Role constant for Plexus component lookup
     */
    String ROLE = ClasspathTransformation.class.getName();
    
    /**
     * Transforms a metadata graph into a classpath container
     * @param dirtyGraph metadata graph to transform
     * @param scope artifact scope for filtering
     * @param resolve whether to resolve artifacts during transformation
     * @return ClasspathContainer with transformed classpath
     * @throws ClasspathTransformationException if transformation fails
     */
    ClasspathContainer transform(MetadataGraph dirtyGraph, ArtifactScopeEnum scope, boolean resolve) 
                               throws ClasspathTransformationException;
}

DefaultClasspathTransformation

Default implementation of ClasspathTransformation.

/**
 * Default implementation of ClasspathTransformation
 */
public class DefaultClasspathTransformation implements ClasspathTransformation {
    /**
     * Transforms a metadata graph into a classpath container
     */
    public ClasspathContainer transform(MetadataGraph dirtyGraph, ArtifactScopeEnum scope, boolean resolve) 
                                      throws ClasspathTransformationException;
}

GraphConflictResolver

Interface for resolving conflicts in metadata graphs.

/**
 * Interface for resolving conflicts in metadata graphs
 */
public interface GraphConflictResolver {
    /**
     * Role constant for Plexus component lookup
     */
    String ROLE = GraphConflictResolver.class.getName();
    
    /**
     * Resolves conflicts in a metadata graph
     * @param graph metadata graph with potential conflicts
     * @param scope artifact scope for resolution context
     * @param localRepository local repository
     * @return MetadataGraph with conflicts resolved
     * @throws GraphConflictResolutionException if resolution fails
     */
    MetadataGraph resolveConflicts(MetadataGraph graph, ArtifactScopeEnum scope,
                                 ArtifactRepository localRepository) 
                                 throws GraphConflictResolutionException;
}

Metadata Graph Components

MetadataGraph

Represents dependency metadata as a directed graph.

/**
 * Represents dependency metadata as a directed graph
 */
public class MetadataGraph {
    /**
     * Creates empty metadata graph
     */
    public MetadataGraph();
    
    /**
     * Creates metadata graph with root vertex
     * @param root root vertex for the graph
     */
    public MetadataGraph(MetadataGraphVertex root);
    
    /**
     * Gets the root vertex of the graph
     * @return root MetadataGraphVertex
     */
    public MetadataGraphVertex getRoot();
    
    /**
     * Sets the root vertex of the graph
     * @param root root vertex to set
     */
    public void setRoot(MetadataGraphVertex root);
    
    /**
     * Gets all vertices in the graph
     * @return Collection of MetadataGraphVertex objects
     */
    public Collection<MetadataGraphVertex> getVertices();
    
    /**
     * Adds a vertex to the graph
     * @param vertex vertex to add
     */
    public void addVertex(MetadataGraphVertex vertex);
    
    /**
     * Gets all edges in the graph
     * @return Collection of MetadataGraphEdge objects
     */
    public Collection<MetadataGraphEdge> getEdges();
    
    /**
     * Adds an edge to the graph
     * @param edge edge to add
     */
    public void addEdge(MetadataGraphEdge edge);
}

MetadataGraphVertex

Represents a vertex (node) in the metadata graph.

/**
 * Represents a vertex (node) in the metadata graph
 */
public class MetadataGraphVertex {
    /**
     * Creates vertex with artifact metadata
     * @param metadata artifact metadata for this vertex
     */
    public MetadataGraphVertex(ArtifactMetadata metadata);
    
    /**
     * Gets the artifact metadata for this vertex
     * @return ArtifactMetadata object
     */
    public ArtifactMetadata getMetadata();
    
    /**
     * Sets the artifact metadata for this vertex
     * @param metadata artifact metadata to set
     */
    public void setMetadata(ArtifactMetadata metadata);
    
    /**
     * Gets incoming edges to this vertex
     * @return List of incoming MetadataGraphEdge objects
     */
    public List<MetadataGraphEdge> getIncomingEdges();
    
    /**
     * Gets outgoing edges from this vertex
     * @return List of outgoing MetadataGraphEdge objects
     */
    public List<MetadataGraphEdge> getOutgoingEdges();
    
    /**
     * Adds an incoming edge
     * @param edge incoming edge to add
     */
    public void addIncomingEdge(MetadataGraphEdge edge);
    
    /**
     * Adds an outgoing edge
     * @param edge outgoing edge to add
     */
    public void addOutgoingEdge(MetadataGraphEdge edge);
}

MetadataGraphEdge

Represents an edge (dependency relationship) in the metadata graph.

/**
 * Represents an edge (dependency relationship) in the metadata graph
 */
public class MetadataGraphEdge {
    /**
     * Creates edge between vertices
     * @param from source vertex
     * @param to target vertex
     * @param scope dependency scope
     */
    public MetadataGraphEdge(MetadataGraphVertex from, MetadataGraphVertex to, ArtifactScopeEnum scope);
    
    /**
     * Gets the source vertex
     * @return source MetadataGraphVertex
     */
    public MetadataGraphVertex getFrom();
    
    /**
     * Gets the target vertex
     * @return target MetadataGraphVertex
     */
    public MetadataGraphVertex getTo();
    
    /**
     * Gets the dependency scope
     * @return ArtifactScopeEnum representing the scope
     */
    public ArtifactScopeEnum getScope();
    
    /**
     * Sets the dependency scope
     * @param scope scope to set
     */
    public void setScope(ArtifactScopeEnum scope);
    
    /**
     * Checks if this is an optional dependency
     * @return true if dependency is optional
     */
    public boolean isOptional();
    
    /**
     * Sets whether this is an optional dependency
     * @param optional true if dependency should be optional
     */
    public void setOptional(boolean optional);
}

ClasspathContainer

Container for classpath artifacts after transformation.

/**
 * Container for classpath artifacts after transformation
 */
public class ClasspathContainer {
    /**
     * Creates empty classpath container
     */
    public ClasspathContainer();
    
    /**
     * Gets classpath artifacts
     * @return List of Artifact objects in classpath order
     */
    public List<Artifact> getClasspath();
    
    /**
     * Sets classpath artifacts
     * @param classpath list of artifacts to set
     */
    public void setClasspath(List<Artifact> classpath);
    
    /**
     * Adds an artifact to the classpath
     * @param artifact artifact to add
     */
    public void addArtifact(Artifact artifact);
    
    /**
     * Gets conflicted dependencies
     * @return Map of conflicted artifacts with their alternatives
     */
    public Map<Artifact, List<Artifact>> getConflicts();
    
    /**
     * Adds a conflict resolution
     * @param chosen chosen artifact
     * @param alternatives list of alternative artifacts that were rejected
     */
    public void addConflict(Artifact chosen, List<Artifact> alternatives);
}

Usage Examples

Basic Metadata Retrieval

import org.apache.maven.repository.metadata.MetadataSource;
import org.apache.maven.repository.metadata.DefaultMetadataSource;
import org.apache.maven.repository.metadata.MetadataResolution;

// Retrieve metadata for an artifact
MetadataSource metadataSource = new DefaultMetadataSource();
ArtifactMetadata artifactMetadata = // ... create artifact metadata

try {
    MetadataResolution resolution = metadataSource.retrieve(
        artifactMetadata,
        localRepository,
        remoteRepositories
    );
    
    System.out.println("Metadata retrieved successfully");
    MetadataGraph graph = resolution.getMetadataGraph();
    System.out.println("Graph has " + graph.getVertices().size() + " vertices");
    
} catch (MetadataRetrievalException e) {
    System.err.println("Metadata retrieval failed: " + e.getMessage());
}

Classpath Transformation

import org.apache.maven.repository.metadata.ClasspathTransformation;
import org.apache.maven.repository.metadata.DefaultClasspathTransformation;
import org.apache.maven.repository.metadata.ClasspathContainer;
import org.apache.maven.artifact.ArtifactScopeEnum;

// Transform metadata graph to classpath
ClasspathTransformation transformation = new DefaultClasspathTransformation();
MetadataGraph graph = // ... obtain metadata graph

try {
    ClasspathContainer container = transformation.transform(
        graph,
        ArtifactScopeEnum.runtime,
        true // resolve artifacts
    );
    
    List<Artifact> classpath = container.getClasspath();
    System.out.println("Classpath contains " + classpath.size() + " artifacts");
    
    // Print classpath
    for (Artifact artifact : classpath) {
        System.out.println("  " + artifact.getGroupId() + ":" + artifact.getArtifactId() + 
                          ":" + artifact.getVersion());
    }
    
    // Check for conflicts
    Map<Artifact, List<Artifact>> conflicts = container.getConflicts();
    if (!conflicts.isEmpty()) {
        System.out.println("Resolved " + conflicts.size() + " conflicts");
    }
    
} catch (ClasspathTransformationException e) {
    System.err.println("Classpath transformation failed: " + e.getMessage());
}

Building Metadata Graph

// Build metadata graph manually
MetadataGraph graph = new MetadataGraph();

// Create root vertex
ArtifactMetadata rootMetadata = // ... create root artifact metadata
MetadataGraphVertex rootVertex = new MetadataGraphVertex(rootMetadata);
graph.setRoot(rootVertex);

// Add dependency vertices
ArtifactMetadata depMetadata = // ... create dependency metadata
MetadataGraphVertex depVertex = new MetadataGraphVertex(depMetadata);
graph.addVertex(depVertex);

// Create edge between root and dependency
MetadataGraphEdge edge = new MetadataGraphEdge(
    rootVertex, 
    depVertex, 
    ArtifactScopeEnum.compile
);
graph.addEdge(edge);

// Add edges to vertices
rootVertex.addOutgoingEdge(edge);
depVertex.addIncomingEdge(edge);

System.out.println("Created graph with " + graph.getVertices().size() + " vertices");
System.out.println("Graph has " + graph.getEdges().size() + " edges");

Conflict Resolution

import org.apache.maven.repository.metadata.GraphConflictResolver;

// Resolve conflicts in metadata graph
GraphConflictResolver resolver = // ... get resolver instance
MetadataGraph conflictedGraph = // ... graph with conflicts

try {
    MetadataGraph resolvedGraph = resolver.resolveConflicts(
        conflictedGraph,
        ArtifactScopeEnum.compile,
        localRepository
    );
    
    System.out.println("Conflicts resolved");
    System.out.println("Resolved graph has " + resolvedGraph.getVertices().size() + " vertices");
    
} catch (GraphConflictResolutionException e) {
    System.err.println("Conflict resolution failed: " + e.getMessage());
}

Complete Metadata Processing Workflow

public ClasspathContainer processMetadata(ArtifactMetadata rootArtifact) {
    try {
        // Step 1: Retrieve metadata
        MetadataSource metadataSource = new DefaultMetadataSource();
        MetadataResolution resolution = metadataSource.retrieve(
            rootArtifact,
            localRepository,
            remoteRepositories
        );
        MetadataGraph graph = resolution.getMetadataGraph();
        
        // Step 2: Resolve conflicts
        GraphConflictResolver resolver = // ... get resolver
        MetadataGraph resolvedGraph = resolver.resolveConflicts(
            graph,
            ArtifactScopeEnum.runtime,
            localRepository
        );
        
        // Step 3: Transform to classpath
        ClasspathTransformation transformation = new DefaultClasspathTransformation();
        ClasspathContainer container = transformation.transform(
            resolvedGraph,
            ArtifactScopeEnum.runtime,
            true
        );
        
        // Step 4: Report results
        System.out.println("Processed metadata for " + rootArtifact);
        System.out.println("Final classpath: " + container.getClasspath().size() + " artifacts");
        System.out.println("Conflicts resolved: " + container.getConflicts().size());
        
        return container;
        
    } catch (Exception e) {
        throw new RuntimeException("Metadata processing failed", e);
    }
}

Exception Handling

MetadataRetrievalException

/**
 * Exception thrown when metadata retrieval fails
 */
public class MetadataRetrievalException extends Exception {
    /**
     * Creates exception with message
     * @param message error message
     */
    public MetadataRetrievalException(String message);
    
    /**
     * Creates exception with message and cause
     * @param message error message
     * @param cause underlying cause
     */
    public MetadataRetrievalException(String message, Throwable cause);
}

ClasspathTransformationException

/**
 * Exception thrown when classpath transformation fails
 */
public class ClasspathTransformationException extends Exception {
    /**
     * Creates exception with message
     * @param message error message
     */
    public ClasspathTransformationException(String message);
    
    /**
     * Creates exception with message and cause
     * @param message error message
     * @param cause underlying cause
     */
    public ClasspathTransformationException(String message, Throwable cause);
}

GraphConflictResolutionException

/**
 * Exception thrown when graph conflict resolution fails
 */
public class GraphConflictResolutionException extends Exception {
    /**
     * Creates exception with message
     * @param message error message
     */
    public GraphConflictResolutionException(String message);
    
    /**
     * Creates exception with message and cause
     * @param message error message
     * @param cause underlying cause
     */
    public GraphConflictResolutionException(String message, Throwable cause);
}

Migration Notes

The metadata processing system in maven-compat is maintained for backward compatibility. Modern Maven 3.x applications use the Eclipse Aether dependency resolution system instead of this legacy metadata graph approach.

Install with Tessl CLI

npx tessl i tessl/maven-org-apache-maven--maven-compat

docs

artifact-management.md

index.md

legacy-repository-system.md

metadata-processing.md

profile-management.md

project-building.md

repository-operations.md

runtime-information.md

tile.json