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 Summary
Modifier and TypeMethodDescriptionvoidaddArtifact(Artifact artifact) Registers anArtifactalong with its associated POM.voidRegisters aPominto the workspace.findArtifact(org.eclipse.aether.artifact.Artifact artifact) Attempts to resolve the artifact file for the given artifact from the workspace.findVersions(org.eclipse.aether.artifact.Artifact artifact) Lists all known versions of the given artifact in the workspace.static ProjectWorkspaceReaderReturns the singleton instance of this workspace reader.org.eclipse.aether.repository.WorkspaceRepositoryReturns the workspace repository used for this reader.
-
Method Details
-
addPom
Registers aPominto the workspace. Only POMs backed by a file are accepted and cached.- Parameters:
pom- the POM to register
-
addArtifact
Registers anArtifactalong 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:
getRepositoryin interfaceorg.eclipse.aether.repository.WorkspaceReader- Returns:
- the workspace repository
-
findArtifact
Attempts to resolve the artifact file for the given artifact from the workspace.- Specified by:
findArtifactin interfaceorg.eclipse.aether.repository.WorkspaceReader- Parameters:
artifact- the artifact to locate- Returns:
- the associated file if found, or
nullif not registered
-
findVersions
Lists all known versions of the given artifact in the workspace.- Specified by:
findVersionsin interfaceorg.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
Returns the singleton instance of this workspace reader. Creates the instance lazily and ensures thread safety.- Returns:
- the global
ProjectWorkspaceReaderinstance
-