Class ProjectWorkspaceReader

java.lang.Object
org.apache.maven.resolver.internal.ant.ProjectWorkspaceReader
All Implemented Interfaces:
org.eclipse.aether.repository.WorkspaceReader

public class ProjectWorkspaceReader extends Object implements org.eclipse.aether.repository.WorkspaceReader
Workspace reader caching available POMs and artifacts for ant builds.

This reader helps Maven Resolver resolve artifacts and POMs from the build workspace without accessing a remote or local repository, useful during dependency resolution and POM inheritance scenarios where temporary or generated models are involved.

<pom> elements are cached if they are defined by the 'file'-attribute, as they reference a backing pom.xml file that can be used for resolution with Aether. <artifact> elements are cached if they directly define a 'pom'-attribute or child. The POM may be file-based or in-memory.

  • Method Details

    • addPom

      public void addPom(Pom pom)
      Registers a Pom into the workspace. Only POMs backed by a file are accepted and cached.
      Parameters:
      pom - the POM to register
    • addArtifact

      public void addArtifact(Artifact artifact)
      Registers an Artifact along with its associated POM. Only artifacts that reference a POM are accepted.
      Parameters:
      artifact - the artifact to register
    • getRepository

      public org.eclipse.aether.repository.WorkspaceRepository getRepository()
      Returns the workspace repository used for this reader. This is always named "ant".
      Specified by:
      getRepository in interface org.eclipse.aether.repository.WorkspaceReader
      Returns:
      the workspace repository
    • findArtifact

      public File findArtifact(org.eclipse.aether.artifact.Artifact artifact)
      Attempts to resolve the artifact file for the given artifact from the workspace.
      Specified by:
      findArtifact in interface org.eclipse.aether.repository.WorkspaceReader
      Parameters:
      artifact - the artifact to locate
      Returns:
      the associated file if found, or null if not registered
    • findVersions

      public List<String> findVersions(org.eclipse.aether.artifact.Artifact artifact)
      Lists all known versions of the given artifact in the workspace.
      Specified by:
      findVersions in interface org.eclipse.aether.repository.WorkspaceReader
      Parameters:
      artifact - the artifact (ignoring version) to search for
      Returns:
      list of available versions; may be empty but never null
    • getInstance

      public static ProjectWorkspaceReader getInstance()
      Returns the singleton instance of this workspace reader. Creates the instance lazily and ensures thread safety.
      Returns:
      the global ProjectWorkspaceReader instance